I\'m sending an email in Azure Functions using the SendGrid bindings. As part of the contents of that email, I\'d like to include a link to one of the HTTP methods in the Azure
try the following two steps:
get the host master key:
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourcegroupName}/providers/Microsoft.Web/sites/{functionApp}/functions/admin/masterkey?api-version=2016-08-01
Get the function keys:
GET https://{functionApp}.azurewebsites.net/admin/functions/{functionName}/keys?code={masterKeyFromStep1}
response from the step 2:
{
"keys": [
{
"name": "default",
"value": "xxxxxxxxxxxxxxxxxxxxxx"
}
],
"links": [
{
"rel": "self",
"href": "https://myFncApp.azurewebsites.net/admin/functions/myFunction/keys"
}
]
}
Update:
Note, that the step 1 requires an authorization header in the format:
Authorization: Bearer bearerToken
where a bearerToken string can be obtained from Azure Active Directory (AAD), see the following code snippet of the example:
private string AccessToken(string clientID)
{
string redirectUri = "https://login.live.com/oauth20_desktop.srf";
authContext = new AuthenticationContext("https://login.windows.net/common/oauth2/authorize", TokenCache.DefaultShared);
var ar = authContext.AcquireTokenAsync("https://management.azure.com/", clientID, new Uri(redirectUri), new PlatformParameters(PromptBehavior.SelectAccount)).Result;
return ar.AccessToken;
}
Note, that the clientID is the quid of your registered application in the AAD with an API access permission for Windows Azure Service Management API.