Generate Azure Function's Access Code on the fly programmatically

对着背影说爱祢 提交于 2020-07-31 04:46:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!