Forum Discussion
Bicep Error While Integration API Management with Function App
The portal "Import Function App" experience does more than create an APIM API. It discovers HTTP-triggered functions, creates or uses a host key, stores that key as an APIM named value, and wires the backend/API operation details. In Bicep you usually need to model those pieces explicitly.
The safer automation pattern is:
- Expose an OpenAPI definition from the Function App, or generate one during build.
- Deploy/import the APIM API from that OpenAPI document.
- Create a backend or named value for the Function host key.
- Add an APIM policy to send the function key, unless you are using managed identity/EasyAuth instead.
- If APIM and Function App are in different resource groups, use existing resources with the correct scope in Bicep.
If the Bicep error is around listKeys() or resource scope, check that the module/resource is scoped to the Function App resource group and that the API version supports the key operation you are calling.
Useful docs:
https://learn.microsoft.com/azure/api-management/import-function-app-as-api
https://learn.microsoft.com/azure/api-management/import-api-from-oas
https://learn.microsoft.com/azure/azure-functions/functions-openapi-definition