如何在 Azure 容器实例中设置 cloud_RoleName?

How to set cloud_RoleName in Azure Container Instances?

我们已将 Linux 上的 Azure Functions 部署到 Azure 容器实例。

不幸的是,应用程序洞察日志记录使用默认 ILogger 根本不显示我的 cloud_RoleName。为了按容器查询日志,我需要将 cloud_RoleName 设置为容器镜像的名称。

如何设置此遥测 属性 而无需直接使用遥测客户端?

kudu we managed to set the cloud_RoleName property by adding this environment variable to our ARM template in the Microsoft.ContainerInstance/containerGroups section in the ContainerProperties EnvironmentVariable数组中所述:

{
    "name": "WEBSITE_SITE_NAME",
    "value": "[parameters('containerGroups_name')]"
}

现在 AppInsights 中的日志包含 WEBSITE_SITE_NAME 变量中设置的值,我们可以按如下方式轻松查询我们的日志:

traces | where cloud_RoleName == "containerName"

通过设置 WEBSITE_INSTANCE_ID 环境变量,这也可能适用于 cloud_RoleInstance