Function Apps, Logic Apps and App Services can be used to expose APIs within Azure API Management which is an easy way to deploy serverless microservices. You can see this capability in the Azure portal below within API Management:
Like most readers, I like to script everything, so I was initially frustrated when I couldn’t replicate this operation in the Azure cli, REST, PowerShell, or any of the other SDKs or IaC tools. Others shared my frustration as seen here.
I was nearly resigned to using click ops in the portal (arrrgh) before I worked out this workaround.
The Solution
There is a bit more prep work required to automate this process, but it is well worth it.
- Create an OpenApi (or Swagger spec or WADL) specification document, as seen below (use the absolute URL for your Function App in the
url
parameter):
- Use the
az apim api import
function (not theaz apim api create
function), as shown here:
- Associate the API with a product (which is how you can rate limit APIs)
That’s it! You can now access your function via the API gateway using the gateway url or via the developer portal as seen below:
if you have enjoyed this post, please consider buying me a coffee ☕ to help me keep writing!