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

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

问题描述

我有几个 Azure 函数(用 c# 编写).. 我已将它们的 URL 提供给不同的团队调用invoke .. 我注意到后缀的访问代码总是相同的,因此会带来安全风险..

I have couple of Azure functions (written in c#) .. URL of which i have given to a different team to callinvoke .. 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天全站免登陆