以编程方式即时生成Azure Function的访问代码 [英] Generate Azure Function's Access Code on the fly programmatically

查看:54
本文介绍了以编程方式即时生成Azure Function的访问代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个Azure函数(用C#编写)..我已将URL提供给另一个团队以调用\调用..我注意到后缀的访问代码始终相同,因此存在安全风险..

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 ..

是否可以通过编程方式即时生成Azure函数的访问代码并将其附加到函数的URL ..以便每次调用都具有唯一生成的访问代码?

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 ?

请指导.谢谢.

推荐答案

是的,您可以使用azure cli/rest api/powershell来做到这一点:

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"

来源:

https://markheath.net/post/managing-azure-functions-keys-2

如果需要,还可以使用REST API达到相同的结果:

if you want, you can also achieve the same result using REST API:

https://docs.microsoft.com/en-us/rest/api/appservice/webapps/createorupdatefunctionsecret

这篇关于以编程方式即时生成Azure Function的访问代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆