Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Dynamic Access to Azure Functions Host Keys without KUDU
# NOTE: This is NOT a real resource group name nor function app name. Use yours.
$resourceGroupName = "my-resource-group"
$functionAppName = "my-azure-function"
$accessTokenHeader = @{ "Authorization" = "Bearer " + $auth.access_token }
$azureRmBaseUri = "https://management.azure.com"
$azureRmApiVersion = "2016-08-01"
$azureRmResourceType = "Microsoft.Web/sites"
$azureRmResourceId = "/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/$azureRmResourceType/$functionAppName"
$azureRmAdminBearerTokenEndpoint = "/functions/admin/token"
$adminBearerTokenUri = $azureRmBaseUri + $azureRmResourceId + $azureRmAdminBearerTokenEndpoint + "?api-version=" + $azureRmApiVersion
$adminBearerToken = Invoke-RestMethod -Method Get -Uri $adminBearerTokenUri -Headers $accessTokenHeader
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment