Share via

Azure function and tags request using management.azure.com

Blaise Lugeon 26 Reputation points
2022-09-09T16:09:33.657+00:00

Hi,

I have a strange behavior within an Azure Function since last month.

I have a script running in an Azure function that use the following REST API in the following order

  1. GET ACCESS TOKEN: 'https://login.microsoftonline.com/<tenant_ID>/oauth2/token' with the payload grant_type=client_credentials&client_id=<app_client_ID>&client_secret=<client_SECRET>&resource=https%3A%2F%2Fmanagement.azure.com%2F
  2. GET LIST OF SUBSCRIPTIONS OF THE TENANT: 'https://management.azure.com/subscriptions?api-version=2020-01-01' using the access token
  3. GET COST OF EACH SUBSCRIPTION: 'https://management.azure.com/subscriptions/<subscription_ID>/providers/Microsoft.CostManagement/query?api-version=2019-11-01' using the access token
  4. GET RESOURCE GROUPS OF EACH SUBSCRIPTION: ''https://management.azure.com/subscriptions/<subscription_ID>/resourcegroups?api-version=2020-06-01' using the access token
  5. GET TAGS OF EACH SUBSCRIPTION: 'https://management.azure.com/subscriptions/<subscription_ID>/providers/Microsoft.Resources/tags/default?api-version=2021-04-01' using the access token

a) The script works properly locally using my computer.
b) The script works properly in Azure function until step 5, which fails returning 'AuthorizationFailed'
c) Using the same token generated in b) I dumped, I use Postman to get the same request locally using my computer... successfully!

The only conclusion for me is that the Azure function blocks "somewhere within the network" my specific request https://management.azure.com/subscriptions/<subscription_ID>/providers/Microsoft.Resources/tags/default?api-version=2021-04-01

This code worked properly last month... Since then, the only thing I did is moving the resource Azure function from one subscription to another one, what should not affect my script or even the rights within Azure or my application... and Yes, I already tried to create again the Azure function from scratch with the same result...

Any idea?

Thanks

Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.

Cost Management
Cost Management

A Microsoft offering that enables tracking of cloud usage and expenditures for Azure and other cloud providers.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.