![](/img/trans.png)
[英]Azure Bicep giving InvalidTemplateDeployment error for Azure App Service Plan deployment
[英]Accessing the App (client) ID from an Azure App Service in bicep
在二头肌中,我正在配置一个 Azure API 管理策略,该策略为特定的后端应用服务启用托管服务标识。
这通常通过像这样设置 XML 片段来完成:
<policies>
<inbound>
<authentication-managed-identity resource="4d192d04-XXXX-461f-a6ab-XXXXXXXXXXXX" />
<base />
</inbound>
</policies>
我现在正在寻找的是如何在我的二头肌模板中从现有应用服务中检索该特定resource
ID。
下面是我现有的二头肌模板中的一些片段:
// The App Service declaration
@description('API Website')
resource backendapi 'Microsoft.Web/sites@2021-03-01' = {
name: 'backend-${environment}'
kind: 'app,linux,container'
location: location
// left out properties, etc for brevity
// This is where I want to retrieve the client ID from that web app, but this fails:
var managed_identity_id = backendapi.identity.principalId
部署上述模板时,出现以下异常(尽管 Visual Studio Code intellisense 指示identity.principalId
有效。
语言表达式属性“身份”不存在,可用属性为“apiVersion、位置、标签、种类、属性、条件、deploymentResourceLineInfo、现有、isConditionTrue、subscriptionId、resourceGroupName、范围、resourceId、referenceApiVersion、isTemplateResource、isAction、provisioningOperation”
所以我的问题是,如何在二头肌文件中从应用服务访问该属性。 其值显示在以下屏幕截图中的属性:
如评论部分所述,您正在寻找 Web 应用身份验证设置: Microsoft.Web sites/config 'authsettingsV2' 2020-12-01
您可以像这样检索 AzureAD Auth 的 clientId:
param webAppName string
resource authsettings 'Microsoft.Web/sites/config@2020-12-01' existing = {
name: '${webAppName}/authsettingsV2'
}
var clientId = authsettings.properties.identityProviders.azureActiveDirectory.registration.clientId
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.