In this challenge you will use Bicep to deploy the Starwars API. The swagger definition for this API is in your storage account. Instead of adding a request header you will remove sensitive information from the outgoing call to the backend service using a Policy fragment. Policy fragments is a feature that let you create policies centrally and then reference them in your API's.
The following image illustrates the steps in this challenge
- Deploy the Starwars API using Bicep from VS Code.
- Add a Policy fragment that removes the request header "Ocp-Apim-Subscription-Key" in the call to the backend service.
- Use Azure CLI to upload the swapi-swagger.json file that is in the root folder to your storage account in the container "swapi".
az storage blob upload -f .\swapi-swagger.json --account-name stg[POSTFIX]hack -c swapi
- Create a Bicep file in VS Code and place it in the infrastructure folder. Use the "existing" keyword to reference your APIM instance.
- Create a new API using Bicep, import the Starwars API from https://stg[YOUR POSTFIX]hack.blob.core.windows.net/swapi/swapi-swagger.json
- Add a subscription using Bicep and connect it to the SWAPI API.
- Use the portal to create a Policy fragment that removes the request header "Ocp-Apim-Subscription-Key" from the outgoing call to the backend service.
- Validate that the outgoing call doesn't expose the "Ocp-Apim-Subscription-Key" that is being used to authenticate against APIM. Use the test functionality in APIM and validate this by looking at the trace logs.
- Starwars API imported and subscription created using Bicep.
- "Ocp-Apim-Subscription-Key" header removed from outgoing call to backend service.
- Microsoft.ApiManagement service/apis reference
- Reuse policy configurations in your API Management policy definitions
- View the solution here, Challenge 3 - Solution
- Challenge 1: Setup the environment
- Challenge 2: Get familiar with Azure API Management (APIM)
- Challenge 3: Use Bicep for deployment to APIM
- Challenge 4: Create a CI/CD GitHub Action and deploy to Container Apps
- Challenge 5: Use the CI/CD GitHub Action to deploy changes to APIM
- Challenge 6: Add a policy using Bicep
- Challenge 7: Managing Development/Production environments.