如何在无人值守的 Azure 函数中检索用户名和密码

How to retrieve UserName and Password in unattended Azure Function

我有一本 运行 当前通过 webhook 调用执行的书,以便在网站上执行一些 powershell 代码。效果很好。

我被指示将此代码转换为 Azure 函数。没什么大不了的,对吧?出色地.... 我能够毫不费力地设置它——我在 VS Studio 中创建它,然后部署到 Azure。 问题是在我需要登录的代码中,我的用户名和密码在脚本中是硬编码的。当我在 运行 书中有 运行 这个时,我打电话给 存储在自动化帐户中的凭据,但在此处似乎不是一个选项。

我看到其他人问过同样的问题,答案往往是“应用程序设置”,这当然不受保护。
这是 运行 无人看管的,所以我(显然)不能要求提供凭据。我是 运行正在使用 PowerShell 7。

如有任何帮助,我们将不胜感激。

您可以使用 Key vault references with Azure Function App to access secrets. You can protect your secrets stored in Key vault using RBAC. Azure function app also provides integration with AAD where you can use Identity instead of secrets. Additionally you can go through this document 了解有关保护 Azure Functions 的更多信息。