Deploys Front Door > APP Gateway > API Management> and conditionally an API running in a Python Flask Web App.
Before deploying the ARM template, create a Key Vault, and Self-Signed SSL Certificate, and upload these to the Key Vault.
Create the Key Vault.
az group create --name ci-lab-full-001 --location eastus
az deployment group create --template-file ./bicep-modules/key-vault.bicep --resource-group ci-lab-full-001
Update the app.json file with the following things.
Property | Description |
---|---|
baseName |
The base name for the resources created. |
deployAppService |
Set to true to deploy the API. |
customDomainNameAPIM |
Custom domain name for APIM, must match SSL certificate. |
keyVaultName |
The name of the Key Vault created in the pre-requisites. |
keyVaultResourceGroup |
The name of the resource group where the Key Vault was created. |
Select the APIM instance and select Custom Domains. Add the custom domain name and the SSL certificate.
Once done, click save. This seems to put APIM into a non-functional state where 'Service is being updated'. This is something to understand better.
The Bicep templates include an optional API hosted in App Service. If deployed, add the API to APIM. Select the APIM instance, APIs, and then from the Add API menu, select App Service. Select the API and then create.
The sample API is not AAD integrated. For demo purposes only, uncheck the Require subscription check box.
Select the Application Gateway > Backend Health, and verify that the API is healthy.
Run the following command against the front door URL to verify that the API GET operation works.
curl https://pef-apim-lab-cke3gaa3ddhbfzee.z01.azurefd.net
Run the following command against the front door URL to verify that the API POST operation works. This has stopped workign with latest deployment updates, need to investigate.
curl --header "Content-Type: application/json" --request POST --data '{"num1": 5, "num2": 7}' https://pef-apim-lab-cke3gaa3ddhbfzee.z01.azurefd.net/sum
The following commands can be used to build and test the API on your development machine.
python3 -m venv .venv
./.venv/bin/Activate.ps1
pip install -r requirements.txt
python app.py
curl --header "Content-Type: application/json" --request POST --data '{"num1": 5, "num2": 7}' http://localhost:5000/sum