问题
I have couple of Azure functions (written in c#) .. URL of which i have given to a different team to call\invoke .. I noticed that the access code which is suffixed is always the same hence poses a security risk ..
Is there a way where we can generate Azure Function's Access Code on the fly programmatically and append it to the function's URL .. so that each and every invocation would have a Uniquely generated access code ?
Please guide. Thanks.
回答1:
Yes, you can do it using azure cli / rest api / powershell:
$keyName = "MyFunctionKey"
$payload = (@{ properties=@{ name=$keyName; value="abcd1234" } } `
| ConvertTo-Json -Compress).Replace('"', '\"')
az rest --method put `
--uri "$resourceId/functions/$functionName/keys/$($keyName)?api-version=2018-11-01" `
--body "$payload"
source:
https://markheath.net/post/managing-azure-functions-keys-2
if you want, you can also achieve the same result using REST API:
https://docs.microsoft.com/en-us/rest/api/appservice/webapps/createorupdatefunctionsecret
来源:https://stackoverflow.com/questions/62783629/generate-azure-functions-access-code-on-the-fly-programmatically