Search code examples
azure-functionsazure-management-api

Restart an azure function app which is not under Azure AD security


I was trying to restart that application by using

https://management.azure.com/subscriptions/{subscription}/resourceGroups/{rGp}/providers/Microsoft.Web/sites/{appName}/restart?api-version=2019-08-01

thing is it was giving me unauthorized status.

Keep that in mind .. that that application is not under Azure AD. Mostly the articles, I read about that issue are using Azure AD.

Question No 1: is it a necessity to add that azure function app in Azure AD?

Question No 2 : i tried that link enter image description here I have no idea how that is getting token for this but a token is added in header of that request. So how can i get that token? (my personal theory about that is that Microsoft is using my organization user to get that token. )

Question No 3 : even that above link and experiment yielded 200K but still activity log of that function app is not showing log of that retart activity . So what that means if that is giving me 200K that means app got restart or not ?


Solution

  • We have did repro in our local environment below are the analysis based on the repro findings.

    Question No 1: is it a necessity to add that azure function app in Azure AD?

    • Azure App Service provides built-in authentication and authorization capabilities (sometimes referred to as "Easy Auth"), so you can sign in users and access data by writing minimal or no code in your web app, RESTful API, and mobile back end, and also Azure Functions. This article describes how App Service helps simplify authentication and authorization for your app.

    Question No 2 : i tried that link have no idea how that is getting token for this but a token is added in header of that request. So how can i get that token? (my personal theory about that is that Microsoft is using my organization user to get that token. )

    • Yes personal theory is correct when ever you log-in to the Azure rest api using you work account a bearer token will be generated based on the object id & client id of the user in azure AD.
    • Here is the link to create the bearer token Azure REST API: How To Create Bearer Token

    Question No 3 : even that above link and experiment yielded 200K but still activity log of that function app is not showing log of that restart activity.So what that means if that is giving me 200K that means app got restart or not ?

    • We had ran the same web app restart api which was shown in the above picture & i am able to see that function app got restarted in the activity log as well with status code as 200.
    • Here is the sample output for reference:

    enter image description here