shaker
shaker

Reputation: 13

ARM template issue boot diagonistic not going to existing storage container

I have the following template , what I want to do is , I have enabled the boot diagonistics and want the bootdiagonistic to go to https://noltu.blob.core.windows.net/lalu which is an existing container.But I am getting the following error The value of parameter bootDiagnostics.storageAccountUri is invalid.Below is the ARM template

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
      "adminUsername": {
        "type": "string",
        "metadata": {
          "description": "Username for the Virtual Machine."
        }
      },
      "adminPassword": {
        "type": "securestring",
        "minLength": 12,
        "metadata": {
          "description": "Password for the Virtual Machine."
        }
      },
      "dnsLabelPrefix": {
        "type": "string",
        "defaultValue": "[toLower(concat(parameters('vmName'),'-', uniqueString(resourceGroup().id, parameters('vmName'))))]",
        "metadata": {
          "description": "Unique DNS Name for the Public IP used to access the Virtual Machine."
        }
      },
      "publicIpName": {
        "type": "string",
        "defaultValue": "myPublicIP",
        "metadata": {
          "description": "Name for the Public IP used to access the Virtual Machine."
        }
      },
      "publicIPAllocationMethod": {
        "type": "string",
        "defaultValue": "Dynamic",
        "allowedValues": [
          "Dynamic",
          "Static"
        ],
        "metadata": {
          "description": "Allocation method for the Public IP used to access the Virtual Machine."
        }
      },
      "publicIpSku": {
        "type": "string",
        "defaultValue": "Basic",
        "allowedValues": [
          "Basic",
          "Standard"
        ],
        "metadata": {
          "description": "SKU for the Public IP used to access the Virtual Machine."
        }
      },
     "blobStorageEndpoint":{
       "type":"string",
       "defaultValue": "blob.core.windows.net"

    },  
    "containerpoint":{
      "type":"string",
      "defaultValue": "lalu"

   },
     "newStorageAccountname":{
      "type":"string",
      "defaultvalue":"noltu"


     },
      "OSVersion": {
        "type": "string",
        "defaultValue": "2019-Datacenter",
        "allowedValues": [
          "2008-R2-SP1",
          "2012-Datacenter",
          "2012-R2-Datacenter",
          "2016-Nano-Server",
          "2016-Datacenter-with-Containers",
          "2016-Datacenter",
          "2019-Datacenter",
          "2019-Datacenter-Core",
          "2019-Datacenter-Core-smalldisk",
          "2019-Datacenter-Core-with-Containers",
          "2019-Datacenter-Core-with-Containers-smalldisk",
          "2019-Datacenter-smalldisk",
          "2019-Datacenter-with-Containers",
          "2019-Datacenter-with-Containers-smalldisk"
        ],
        "metadata": {
          "description": "The Windows version for the VM. This will pick a fully patched image of this given Windows version."
        }
      },
      "vmSize": {
        "type": "string",
        "defaultValue": "Standard_D2_v3",
        "metadata": {
          "description": "Size of the virtual machine."
        }
      },
      "location": {
        "type": "string",
        "defaultValue": "[resourceGroup().location]",
        "metadata": {
          "description": "Location for all resources."
        }
      },
      "vmName": {
        "type": "string",
        "defaultValue": "simple-vm",
        "metadata": {
          "description": "Name of the virtual machine."
        }
      }
    },
    "variables": {
      
      "nicName": "myVMNic",      
      "subnetName": "sub1",      
      "virtualNetworkName": "vnet3",
      "subnetRef": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]",
      "networkSecurityGroupName": "poni"
    },
    "resources": [
  
      {
        "type": "Microsoft.Network/publicIPAddresses",
        "apiVersion": "2020-06-01",
        "name": "[parameters('publicIPName')]",
        "location": "[parameters('location')]",
        "sku": {
          "name": "[parameters('publicIpSku')]"
        },
        "properties": {
          "publicIPAllocationMethod": "[parameters('publicIPAllocationMethod')]",
          "dnsSettings": {
            "domainNameLabel": "[parameters('dnsLabelPrefix')]"
          }
        }
      },
      
   
      {
        "type": "Microsoft.Network/networkInterfaces",
        "apiVersion": "2020-06-01",
        "name": "[variables('nicName')]",
        "location": "[parameters('location')]",
        "dependsOn": [
          "[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIPName'))]",
          
        ],
        "properties": {
          "ipConfigurations": [
            {
              "name": "ipconfig1",
              "properties": {
                "privateIPAllocationMethod": "Dynamic",
                "publicIPAddress": {
                  "id": "[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIPName'))]"
                },
                "subnet": {
                  "id": "[variables('subnetRef')]"
                }
              }
            }
          ]
        }
      },
      {
        "type": "Microsoft.Compute/virtualMachines",
        "apiVersion": "2020-06-01",
        "name": "[parameters('vmName')]",
        "location": "[parameters('location')]",
        "dependsOn": [
          
          "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]"
        ],
        "properties": {
          "hardwareProfile": {
            "vmSize": "[parameters('vmSize')]"
          },
          "osProfile": {
            "computerName": "[parameters('vmName')]",
            "adminUsername": "[parameters('adminUsername')]",
            "adminPassword": "[parameters('adminPassword')]"
          },
          "storageProfile": {
            "imageReference": {
              "publisher": "MicrosoftWindowsServer",
              "offer": "WindowsServer",
              "sku": "[parameters('OSVersion')]",
              "version": "latest"
            },
            "osDisk": {
              "createOption": "FromImage",
              "managedDisk": {
                "storageAccountType": "StandardSSD_LRS"
              }
            },
            "dataDisks": [
              {
                "diskSizeGB": 1023,
                "lun": 0,
                "createOption": "Empty"
              }
            ]
          },
          "networkProfile": {
            "networkInterfaces": [
              {
                "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]"
              }
            ]
          },
          "diagnosticsProfile": {
            "bootDiagnostics": {
              "enabled": true,
              "storageUri": "[concat('http://',parameters('newStorageAccountname'),'.',parameters('blobStorageEndpoint'),'/',parameters('containerpoint'))]"
            
            }
          }
        }
      }
    ],
    "outputs": {
      "hostname": {
        "type": "string",
        "value": "[reference(parameters('publicIPName')).dnsSettings.fqdn]"
      }
    }
  }

Upvotes: 0

Views: 340

Answers (1)

Charles Xu
Charles Xu

Reputation: 31424

The attribute storageUri is used to set the Uri for the storage account, not for the special container. And it will create the container dynamcally. So the attribute storageUri should be like this:

"storageUri": "[concat('http://',parameters('newStorageAccountname'),'.',parameters('blobStorageEndpoint'),'/')]"

See more details here.

Upvotes: 1

Related Questions