ARM template - Azure Container Group Diagnotistics issue

Anonymous
2021-09-05T02:23:36.997+00:00

Looking at creating an ARM template for deploying a container group.

I had an existing instance to copy from, which had been terraformed into place and was working fine, but needed an ARM example for users who wished to deploy without terraform (using the "Deploy a custom template" feature of the portal). As such I exported the config of my working container out as a template, removed a couple of bits which were causing it to error (provisioning state, etc), and gave it a test.

Unfortunately something that we couldn't get working was diagnostic log output to workspace, which was working in the template we exported.

I parameterised the workspaceId and WorkspaceKey, created a new workspace, and grabbed the relevant details from the Client Management page for that Log Analytics Workspace (and confirmed it via the CLI). I can terraform it into place with that ID and key, and I can set it up via CLI and YAML, but when attempting to do so with an ARM template, I get the following error:

{ "status": "Failed", "error": { "code": "InvalidLogAnalyticsWorkspaceKey", "message": "The log analytics setting is invalid. WorkspaceId contains invalid character, e.g. '/', '.', etc." } }

I have confirmed that by removing the diagnostics block, the container deploys successfully, but would like to understand why this is broken and have this addressed by the team if possible.

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
2,820 questions
Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
645 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2021-09-15T11:05:26.933+00:00

    Apologies - just received this notification.

    Template as follows:

    {
        "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "storageAccounts_mtlncdcstorage_name": {
                "defaultValue": "mtlncdcstorage",
                "type": "String"
            },
            "containerGroups_cdc_agent_container_name": {
                "defaultValue": "cdc-container",
                "type": "String"
            },
            "agent_id": {
                "type": "String"
            },
            "id_organization": {
                "type": "String"
            },
            "imageRegistryCredentialsUser": {
                "type": "String"
            },
            "imageRegistryCredentialsPassword": {
                "type": "String"
            },
            "workspaceId": {
                "type": "String"
            },
            "workspaceKey": {
                "type": "String"
            },
            "location": {
                "type": "String",
                "defaultValue": "[resourceGroup().location]"
            },
            "container-dns-name": {
                "type": "String"
            },
            "image_name": {
                "type": "String"
            }
        },
        "variables": {},
        "resources": [
            {
                "type": "Microsoft.ContainerInstance/containerGroups",
                "apiVersion": "2021-03-01",
                "name": "[parameters('containerGroups_cdc_agent_container_name')]",
                "location": "[parameters('location')]",
                "properties": {
                    "sku": "Standard",
                    "containers": [
                        {
                            "name": "cdc-agent-container",
                            "properties": {
                                "image": "[parameters('image_name')]"",
                                "ports": [
                                    {
                                        "protocol": "TCP",
                                        "port": 8080
                                    }
                                ],
                                "environmentVariables": [
                                    {
                                        "name": "ID_AGENT",
                                        "value": "[parameters('agent_id')]"
                                    },
                                    {
                                        "name": "SPRING_PROFILES_ACTIVE",
                                        "value": "dev"
                                    },
                                    {
                                        "name": "ID_ORGANIZATION",
                                        "value": "[parameters('id_organization')]"
                                    }
                                ],
                                "resources": {
                                    "requests": {
                                        "memoryInGB": 16,
                                        "cpu": 4
                                    }
                                }
                            }
                        }
                    ],
                    "restartPolicy": "Always",
                    "ipAddress": {
                        "ports": [
                            {
                                "protocol": "TCP",
                                "port": 8080
                            }
                        ],
                        "ip": "51.140.225.76",
                        "type": "Public",
                        "dnsNameLabel": "[parameters('container-dns-name')]"
                    },
                    "osType": "Linux",
                    "diagnostics": {
                        "logAnalytics": {
                            "workspaceId": "[parameters('workspaceId')]",
                            "workspaceKey": "[parameters('workspaceKey')]"
                        }
                    }
                }
            },
            {
                "type": "Microsoft.Storage/storageAccounts",
                "apiVersion": "2021-04-01",
                "name": "[parameters('storageAccounts_mtlncdcstorage_name')]",
                "location": "[parameters('location')]",
                "sku": {
                    "name": "Standard_LRS",
                    "tier": "Standard"
                },
                "kind": "StorageV2",
                "identity": {
                    "type": "None"
                },
                "properties": {
                    "isNfsV3Enabled": false,
                    "minimumTlsVersion": "TLS1_0",
                    "allowBlobPublicAccess": false,
                    "allowSharedKeyAccess": true,
                    "isHnsEnabled": false,
                    "networkAcls": {
                        "bypass": "AzureServices",
                        "virtualNetworkRules": [],
                        "ipRules": [],
                        "defaultAction": "Allow"
                    },
                    "supportsHttpsTrafficOnly": true,
                    "encryption": {
                        "services": {
                            "file": {
                                "keyType": "Account",
                                "enabled": true
                            },
                            "blob": {
                                "keyType": "Account",
                                "enabled": true
                            }
                        },
                        "keySource": "Microsoft.Storage"
                    },
                    "accessTier": "Hot"
                }
            },
            {
                "type": "Microsoft.Storage/storageAccounts/blobServices",
                "apiVersion": "2021-04-01",
                "name": "[concat(parameters('storageAccounts_mtlncdcstorage_name'), '/default')]",
                "dependsOn": [
                    "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_mtlncdcstorage_name'))]"
                ],
                "sku": {
                    "name": "Standard_LRS",
                    "tier": "Standard"
                },
                "properties": {
                    "cors": {
                        "corsRules": []
                    },
                    "deleteRetentionPolicy": {
                        "enabled": false
                    }
                }
            },
            {
                "type": "Microsoft.Storage/storageAccounts/fileServices",
                "apiVersion": "2021-04-01",
                "name": "[concat(parameters('storageAccounts_mtlncdcstorage_name'), '/default')]",
                "dependsOn": [
                    "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_mtlncdcstorage_name'))]"
                ],
                "sku": {
                    "name": "Standard_LRS",
                    "tier": "Standard"
                },
                "properties": {
                    "cors": {
                        "corsRules": []
                    }
                }
            },
            {
                "type": "Microsoft.Storage/storageAccounts/queueServices",
                "apiVersion": "2021-04-01",
                "name": "[concat(parameters('storageAccounts_mtlncdcstorage_name'), '/default')]",
                "dependsOn": [
                    "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_mtlncdcstorage_name'))]"
                ],
                "properties": {
                    "cors": {
                        "corsRules": []
                    }
                }
            },
            {
                "type": "Microsoft.Storage/storageAccounts/tableServices",
                "apiVersion": "2021-04-01",
                "name": "[concat(parameters('storageAccounts_mtlncdcstorage_name'), '/default')]",
                "dependsOn": [
                    "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_mtlncdcstorage_name'))]"
                ],
                "properties": {
                    "cors": {
                        "corsRules": []
                    }
                }
            },
            {
                "type": "Microsoft.Storage/storageAccounts/blobServices/containers",
                "apiVersion": "2021-04-01",
                "name": "[concat(parameters('storageAccounts_mtlncdcstorage_name'), '/default/', parameters('storageAccounts_mtlncdcstorage_name'))]",
                "dependsOn": [
                    "[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccounts_mtlncdcstorage_name'), 'default')]",
                    "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_mtlncdcstorage_name'))]"
                ],
                "properties": {
                    "defaultEncryptionScope": "$account-encryption-key",
                    "denyEncryptionScopeOverride": false,
                    "publicAccess": "None"
                }
            }
        ]
    }