容器应用程序环境上的功能不支持托管身份

问题描述 投票:0回答:1

我正在尝试使用 bicep 在 azure 容器应用程序环境中构建 azure 函数。我想绑定一些用户分配的托管身份以将函数连接到 cosmosdb。

使用下面的二头肌部署功能后:

resource azfunctionapp 'Microsoft.Web/sites@2022-09-01' = {
  name: functionName
  location: location
  kind: 'functionapp,linux,container,azurecontainerapps'
  identity: {
    type: 'UserAssigned'
    userAssignedIdentities: {
      '${umi.id}': {}
    }
  }
  properties: {
    name: functionName
    managedEnvironmentId:environment.id
    siteConfig: {
    linuxFxVersion: 'Docker|${image}'  
    appSettings: [
        {
          name: 'AzureWebJobsStorage'
          value: azStorageConnectionString
        }
        {
          name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
          value: appi.properties.ConnectionString
        }
        {
          name: 'DOCKER_REGISTRY_SERVER_URL'
          value: '${acrName}.azurecr.io'
        }
        {
          name: 'DOCKER_REGISTRY_SERVER_USERNAME'
          value: acrName
        }
        {
            name: 'DOCKER_REGISTRY_SERVER_PASSWORD'
            value: acr.listCredentials().passwords[0].value
        }
      ]
    }
    
  }
}

我收到如下错误消息:

\"Message\": \"Managed Identity is not supported for Function on Container App Environment. object is not present in the request body.\"

由于azure容器应用程序中的功能现在处于预览状态。如消息所示,现在不支持此功能吗?或者,我的二头肌有什么错误吗?

azure azure-functions
1个回答
0
投票

我提到了这个 MS Document1 MS Document2,并且没有提到为容器应用程序环境中的功能添加托管标识。

此外,Azure 容器应用程序处于预览状态。因此,在预览服务中并非所有功能都可用,但 Microsoft 会定期更新。

作为替代方案,您可以使用 CosmosDB 连接字符串并将其值存储在 keyvault 中,并使用下面的 bicep 文件:-

resource azfunctionapp 'Microsoft.Web/sites@2022-09-01' = {
  name: functionName
  location: location
  kind: 'functionapp,linux,container,azurecontainerapps'
  properties: {
    name: functionName
    managedEnvironmentId: environment.id
    siteConfig: {
      linuxFxVersion: 'Docker|${image}'  
      appSettings: [
        {
          name: 'AzureWebJobsStorage'
          value: azStorageConnectionString
        }
        {
          name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
          value: appi.properties.ConnectionString
        }
        {
          name: 'DOCKER_REGISTRY_SERVER_URL'
          value: '${acrName}.azurecr.io'
        }
        {
          name: 'DOCKER_REGISTRY_SERVER_USERNAME'
          value: acrName
        }
        {
          name: 'DOCKER_REGISTRY_SERVER_PASSWORD'
          value: acr.listCredentials().passwords[0].value
        }
        {
          name: 'CosmosDBConnectionString'
          value: '@Microsoft.KeyVault(SecretUri=<your-secret-uri-in-keyvault>)'
        }
      ]
    }
  }
}

© www.soinside.com 2019 - 2024. All rights reserved.