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
Nuget: Microsoft.Azure.Management.Fluent API can now manage the keys:
using Microsoft.Azure.Management.AppService.Fluent;
var functionApp = AzureInstance.AppServices.FunctionApps.GetByResourceGroup(resourceGroupName, functionAppName);
foreach (var function in functionApp.ListFunctions())
{
var functionName = function.Name.Split('/')[1];
var functionKeys = functionApp.ListFunctionKeys(functionName);
functionKeys.TryGetValue(keyName, out string functionKey);
dict.Add(functionName, functionKey);
}
you can also set new keys: (pass null as secret for auto-generated key)
foreach (var function in functionApp.ListFunctions())
{
var functionName = function.Name.Split('/')[1];
var nameValue = functionApp.AddFunctionKey(functionName, keyName,null);
}
Caveat: To make this work in production, the FunctionApp Identity must have the RBAC Owner Role of the Function App. This is set on the Access Control(IAM) Blade.