黑色桌面背景Azure VM

时间:2016-02-19 12:33:37

标签: azure azure-virtual-machine azure-resource-manager

我正在订阅中部署Windows Azure VM映像,使用他们部署的资源管理模板,期望桌面背景为黑色,如果我启用了BGInfo扩展,则它不起作用。

如果我通过Azure门户部署相同类型的图像,则桌面背景是正确的(Windows ServerBG),BGInfo按预期工作。

这是我正在使用的模板:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": 
  {
    "location": 
    {
      "type": "string",
      "defaultValue": "North Europe",
      "allowedValues": 
      [
        "West US",
        "East US",
        "West Europe",
        "East Asia",
        "Southeast Asia",
        "North Europe"
      ],
      "metadata": 
      {
        "description": "Location of resources"
      }
    },
    "StorageAccount": 
    {
      "type": "string",
      "metadata": 
      {
        "description": "Storage Account Name"
      }
    },
    "storageAccountType": 
    {
      "type": "string",
      "defaultValue": "Standard_LRS",
      "metadata": 
      {
        "description": "Type of the Storage Account"
      }
    },
    "privateIPAddressType": 
    {
      "type": "string",
      "defaultValue": "Static",
      "allowedValues": 
      [
        "Dynamic",
        "Static"
      ],
      "metadata": 
      {
        "description": "Private IP Address Type"
      }
    },
    "privateIPAddress": 
    {
      "type": "string",
      "metadata": 
      {
        "description": "Private IP Address"
      }
    },
    "vmName": 
    {
      "type": "string",
      "metadata": 
      {
        "description": "Name of the VM"
      }
    },
    "vmSize": 
    {
      "type": "string",
      "defaultValue": "Standard_D2",
      "metadata": 
      {
        "description": "Size of the VM"
      }
    },
    "imagePublisher": 
    {
      "type": "string",
      "defaultValue": "MicrosoftWindowsServer",
      "metadata": 
      {
        "description": "Image Publisher"
      }
    },
    "imageOffer": 
    {
      "type": "string",
      "defaultValue": "WindowsServer",
      "metadata": 
      {
        "description": "Image Offer"
      }
    },
    "imageSKU": 
    {
      "type": "string",
      "defaultValue": "2012-R2-Datacenter",
      "metadata": 
      {
        "description": "Image SKU"
      }
    },
    "adminUsername": 
    {
      "type": "string",
      "metadata": 
      {
        "description": "Admin username"
      }
    },
    "adminPassword": 
    {
      "type": "securestring",
      "metadata": 
      {
        "description": "Admin password"
      }
    },
    "existingVNETName": 
    {
      "type": "string",
      "metadata": 
      {
        "description": "Existing VNET that contains the domain controller"
      }
    },
    "existingSubnetName": 
    {
      "type": "string",
      "metadata": 
      {
        "description": "Existing subnet that contains the domain controller"
      }
    },
    "existingVirtualNetworkResourceGroup": 
    {
      "type": "string",
      "metadata": 
      {
        "description": "Name of the existing VNET resource group"
      }
    }
  },
  "variables": 
  {
    "api-version": "2015-05-01-preview",
    "vnetID": "[resourceId(parameters('existingVirtualNetworkResourceGroup'), 'Microsoft.Network/virtualNetworks', parameters('existingVNETName'))]",
    "subnet1Ref": "[concat(variables('vnetID'),'/subnets/',parameters('existingSubnetName'))]",
    "privateNicName": "[concat(parameters('vmName'),'-Production')]",
    "NewStorageAccount": "[concat(parameters('vmName'), parameters('StorageAccount'))]",
    "OSDisk": "[concat(parameters('vmName'),'-OSDisk')]",
    "DataDisk": "[concat(parameters('vmName'),'-DataDisk')]"
  },
  "resources": 
  [

    {
      "apiVersion": "[variables('api-version')]",
      "type": "Microsoft.Storage/storageAccounts",
      "name": "[variables('NewStorageAccount')]",
      "location": "[parameters('location')]",
      "properties": 
      {
        "accountType": "[parameters('storageAccountType')]"
      }
    },
    {
      "apiVersion": "[variables('api-version')]",
      "type": "Microsoft.Network/networkInterfaces",
      "name": "[variables('privateNicName')]",
      "location": "[parameters('location')]",
      "tags": 
      {
        "displayName": "NetworkInterface"     
      },
      "properties": 
      {
        "ipConfigurations": 
        [
          {
            "name": "ipconfig",
            "properties": 
            {
              "privateIPAllocationMethod": "[parameters('privateIPAddressType')]",
              "privateIPAddress": "[parameters('privateIPAddress')]",
              "subnet": 
              {
                "id": "[variables('subnet1Ref')]"
              }
            }
          }       
        ]
      }
    },
    {
      "apiVersion": "[variables('api-version')]",
      "type": "Microsoft.Compute/virtualMachines",
      "name": "[parameters('vmName')]",
      "location": "[parameters('location')]",
      "tags": 
      {
        "displayName": "VirtualMachine"
      },
      "dependsOn": 
      [
        "[concat('Microsoft.Storage/storageAccounts/', variables('newStorageAccount'))]",
        "[concat('Microsoft.Network/networkInterfaces/', variables('privateNicName'))]"
      ],
      "properties": 
      {
        "hardwareProfile": 
        {
          "vmSize": "[parameters('vmSize')]"
        },
        "osProfile": 
        {
          "computerName": "[parameters('vmName')]",
          "adminUsername": "[parameters('adminUsername')]",
          "adminPassword": "[parameters('adminPassword')]"
        },
        "storageProfile": 
        {
          "imageReference": 
          {
            "publisher": "[parameters('imagePublisher')]",
            "offer": "[parameters('imageOffer')]",
            "sku": "[parameters('imageSKU')]",
            "version": "latest"
          },
          "osDisk": 
          {
            "name": "[concat(parameters('vmName'),'-os')]",
            "vhd": 
            {
              "uri": "[concat('http://',variables('newStorageAccount'),'.blob.core.windows.net/vhds/',variables('OSDisk'),'.vhd')]"
            },
            "caching": "ReadWrite",
            "createOption": "FromImage"
          },
          "dataDisks": 
          [
            {
              "name": "[concat(parameters('vmName'),'-data')]",
              "vhd": 
              {
                "Uri": "[concat('http://',parameters('vmName'), parameters('StorageAccount'),'.blob.core.windows.net/vhds/',variables('dataDisk'),'.vhd')]"
              },
              "caching": "None",
              "createOption": "Empty",
              "diskSizeGB": "100",
              "lun": 0
            }
          ]
        },
        "networkProfile": 
        {
          "networkInterfaces": 
          [
            {
              "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('privateNicName'))]"
            }
          ]
        }
      }
    }
  ],

}

我尝试过使用新模板,结果相同,有什么想法吗?

1 个答案:

答案 0 :(得分:0)

在模板中,您不定义bgInfoExtension。如果您在模板中将其定义为“Microsoft.Compute / virtualMachines”下的资源。它将在您部署模板时自动部署。

示例BGInfo扩展ARM模板代码段:

"resources": [{
    "name": "bgInfoExt",
    "type": "extensions",
    "apiVersion": "[variables('api-version')]",
    "location": "[parameters('location')]",
    "dependsOn": [
        "[concat('Microsoft.Compute/virtualMachines/', parameters('vmName'))]"
    ],
    "properties": {
        "publisher": "Microsoft.Compute",
        "type": "BGInfo",
        "typeHandlerVersion": "2.1",
        "settings": { },
        "protectedSettings": null,
        "autoUpgradeMinorVersion": true
    }
}]