Testing ground for C# (Dotnet) Azure Functions
- Install Dotnet 5
- Install Azure Function CLI
- Install Azure CLI
func start
See tutorial for Deploying Bicep with GitHub Actions.
We need to set up Azure for each of our environments by...
- Creating a resource group.
- Creating a service principal for modifying resource group.
- Adding appropriate secrets to the GitHub repository.
- (Issue) Run pipeline to deploy resources, then download Azure Functions Publish Profile and add to repo secrets.
Create resource group.
az login
az group create --name ${AZURE_RG_DEV} --location westus
Create a Service Principal to authenticate the GitHub Actions runner CI/CD process(es) with Azure, for each resource group we wish to deploy to.
az ad sp create-for-rbac --name ${AZURE_SERVICE_PRINCIPAL_NAME_DEV} --role contributor --scopes /subscriptions/${AZURE_SUB_ID}/resourceGroups/${AZURE_RG_DEV} --sdk-auth
Save the output of the Service Principal creation, as this will be out
AZURE_CREDENTIALS_*
secret.
Add secrets to GitHub for GitHub Actions to authenticate with Azure.
Note: The author recommends only setting up the
*_DEV
secrets at first, then setting up additional envs later.
GitHub Repo Secrets Name | Description |
---|---|
AZURE_RG_DEV |
Azure resource group which we created for the project's dev env. |
AZURE_RG_STAG |
Azure resource group which we created for the project's dev env. |
AZURE_RG_PROD |
Azure resource group which we created for the project's prod env. |
AZURE_CREDENTIALS_DEV |
Output of az ad sp create-for-rbac command; service principal credentials. |
AZURE_CREDENTIALS_STAG |
Output of az ad sp create-for-rbac command; service principal credentials. |
AZURE_CREDENTIALS_PROD |
Output of az ad sp create-for-rbac command; service principal credentials. |
AZURE_FUNCTION_PUB_PROF_DEV |
Azure Functions publish profile (XML), downloaded from Azure. |
AZURE_FUNCTION_PUB_PROF_STAG |
Azure Functions publish profile (XML), downloaded from Azure. |
AZURE_FUNCTION_PUB_PROF_PROD |
Azure Functions publish profile (XML), downloaded from Azure. |
AZURE_SUBSCRIPTION |
Azure subscription Id. |
Issue: Function Publish Profile has to be fetched (currently) after deployment. Thus, initial set up will likely end in failure until secret for profile is fetched and set and pipeline is rerun.
The following CICD pipelines exist in this project...
Pipeline | Description | Badge |
---|---|---|
CI Workflow | Runs CI workflow on pull requests to main . |
|
CD Workflow | Deploys dev resources on merge to main . |
|
Release Workflow | Deploys staging and prod resources on push to release/* . |
Insomnia is a fun tool used to test RESTful APIs. (Similar to Postman.)
Example requests are given in an Insomnia collection JSON export.
See the docs to learn how to import request collections.
NOTE: These docs ARE out of date
Create resource group.
az login
az group create --name spacekatt-func-play --location westus
Deploy resources into group
az deployment group create --resource-group spacekatt-func-play --template-file deploy/resources/main.bicep --mode Complete
Publish Function App
func azure functionapp publish fun-spacekattfunc