测试托管身份而不触发Azure功能可能具有挑战性,但是有间接方法可以验证其功能。您可以处理以下方式:
1。验证托管身份配置:
- 确保为您的Azure资源正确启用托管身份(例如Azure函数应用程序)。
- 检查是否将必要的权限分配给Azure Active Directory(AAD)中的托管身份。
2。使用Azure CLI或PowerShell:
- 您可以使用Azure CLI或PowerShell来测试托管身份是否可以进行身份验证并获得访问令牌。这不需要触发Azure功能。
- 例如,您可以使用azure cli命令`az帐户获取token`来测试托管身份是否可以获取令牌。
3。具有Azure Arc的本地开发:
- 如[3]所述,您可以在Azure Arc中注册本地计算机以分配托管身份。这使您可以在本地测试托管身份身份验证,而无需部署到Azure。
4。监视登录日志:
- 使用诸如Azure托管身份登录测试之类的工具来监视失败尝试的登录日志。这可以帮助验证托管身份是否尝试正确身份验证而无需触发函数[1]。
5。使用其他Azure资源进行测试:
- 如果您使用其他使用相同的托管身份的Azure资源(例如Azure SQL或存储),则可以针对这些资源测试身份验证以确保身份正常工作。
这些方法允许您在不直接触发Azure函数的情况下验证托管身份功能。
引用:
[1] https://www.eginnovations.com/documentation/microsoft-azure-active-directory/azure-managed-nideity-indistity-sign-ins-ins-test.htm
[2] https://codebankblog.wordpress.com/2020/06/27/azure-function-with-managed-managed-indistity-andity-andity-and-azure-sql-db/
[3] https://www.foxdeploy.com/blog/how-to-migrate-migrate-an-azure-function-app-to-sapp-to-use-a-managed-indistity.html
[4] https://learn.microsoft.com/en-us/azure/azure-functions/functions-nistity-connections-connections-tutorial-2
[5] https://learn.microsoft.com/en-us/azure/spring-apps/basic-andard/tutorial-managed-indistities-functions
[6] https://github.com/azure/azure-funtsions-host/issues/6423
[7] https://www.codit.eu/blog/setting-up-authentication-on-azure-functions-using-iusing-microsoft-indistity-provider/
[8] https://docs.azure.cn/en-us/azure-functions/functions-reference
[9] https://pnp.github.io/pnpcore/demos/demo.azfunction.managedidentityv2/readme.html
[10] https://www.red-gate.com/simple-talk/cloud/azure/azure-function-and-yser-aseer-managed-indistities/