This is a demo of using Bicep extensibility to deploy a dotnet application to a Kubernetes cluster. The application itself allows you to build a .bicep
file via HTTP request. The build & deployment process is fully automated via GitHub Actions.
- Fork this repo, open the forked repo in Codespaces
- Open ./initial_setup.sh and modify the values of
repoOwner
,repoName
,rgName
&rgLocation
- Log in to Az CLI
- Run
./initial_setup.sh <tenantId>, <subscriptionId>
- The output should contain 3 env variables
ACR_CLIENT_ID
,ACR_SUBSCRIPTION_ID
&ACR_TENANT_ID
. Save each one as a GitHub Repo Secret. - Modify ./deploy/main.bicepparam to contain desired values for your AKS cluster.
- Modify the
AKS_RG_NAME
variable in ./.github/workflows/cd.yml to match the value ofrgName
used in step 2. - Push to your
main
branch. GitHub Actions should build & deploy the .NET application to an AKS cluster! - To test the live service, check the GitHub Actions output for the cluster DNS name. Replace
bicepbuild.eastus.cloudapp.azure.com
with this value in the testing commands below.
- Open in Codespaces
- Build:
docker build -t bicepbuild:latest ./src
- Run:
docker run -p 8001:80 bicepbuild:latest ./src
- Test locally:
- Build:
curl -X POST http://localhost:8001/build \ -H 'Content-Type: application/json' \ -d '{"bicepContents": "param foo string"}'
- Decompile:
curl -X POST http://localhost:8001/decompile \ -H 'Content-Type: application/json' \ -d '{"template": "{\n \"$schema\": \"https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#\",\n \"contentVersion\": \"1.0.0.0\",\n \"parameters\": {\n \"foo\": {\n \"type\": \"string\"\n }\n },\n \"resources\": []\n}"}'
- Build:
- Build:
curl -X POST http://bicepbuild.eastus.cloudapp.azure.com/build \ -H 'Content-Type: application/json' \ -d '{"bicepContents": "param foo string"}'
- Decompile:
curl -X POST http://bicepbuild.eastus.cloudapp.azure.com/decompile \ -H 'Content-Type: application/json' \ -d '{"template": "{\n \"$schema\": \"https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#\",\n \"contentVersion\": \"1.0.0.0\",\n \"parameters\": {\n \"foo\": {\n \"type\": \"string\"\n }\n },\n \"resources\": []\n}"}'