Home › Azure › Securing Azure App Services with Subscriptions
Azure · Jan 30, 2021

Securing Azure App Services with Subscriptions

In this post, we will look at how to secure an Azure app service with a subscription. We will do this by adding the App Service to Azure API Management.

First, we have an Azure app service like below:

Let’s add this to API Management (APIM). Go to APIM and click Create:

Give the APIM a name, and click Review + Create, then Create:

Now let’s go to our new APIM:

And add our App Service:

Scrolling down in the API settings, we can see Subscription Required:

Now let’s try to access the API through Postman. We can get the URL of the API from the Settings menu:

Sending this through Postman, we get a 401 error, “Access denied due to missing subscription key. Make sure to include subscription key when making requests to an API”:

In APIM, go to Subscriptions, and choose a subscription. I will choose the build-in all access subscription:

You can select one, then Show/Hide Keys to reveal the actual key, then copy they key:

Now in Postman, go to the Headers tab and add a key for Ocp-Apim-Subscription-Key, and paste the key value into the Value section. Then click Send, and we see we get a response from our API:

You have now required your API to provide a subscription.

Leave a Reply

Your email address will not be published. Required fields are marked *

Carl de Souza
KEEP LEARNING. KEEP BUILDING.

Explore AI, agents & Microsoft technology.

I share practical ideas, tutorials, and videos about AI, AI agents, Microsoft technologies, and the Power Platform.