Created
July 25, 2020 21:56
-
-
Save TomaszOledzki/1c186db495d66df9dbddd017b4bf2c1c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script variables. | |
$functionAppId = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{functionAppName}'; | |
$functionAppKey = @{ | |
Name = 'ApiKey' | |
Value = '<my-secret-api-key>' | |
}; | |
$headers = @{Authorization = ("Bearer {0}" -f $(GetToken))}; | |
$body = @{Properties = $functionAppKey} | ConvertTo-Json; | |
## List api keys | |
Invoke-WebRequest ` | |
-Method POST ` | |
-Headers $headers ` | |
-Uri $("https://management.azure.com/{0}/host/default/listkeys?api-version=2019-08-01" -f $functionAppId); | |
## Create/Update api keys | |
Invoke-WebRequest ` | |
-Method PUT ` | |
-Headers $headers ` | |
-Body $body ` | |
-ContentType "application/json" ` | |
-Uri $("https://management.azure.com/{0}/host/default/functionKeys/{1}?api-version=2019-08-01" -f $functionAppId,$functionAppKey.name); | |
## Delete api key | |
Invoke-WebRequest ` | |
-Method DELETE ` | |
-Headers $headers ` | |
-Uri $("https://management.azure.com/{0}/host/default/functionKeys/{1}?api-version=2019-08-01" -f $functionAppId,$functionAppKey.Name); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment