代码之家  ›  专栏  ›  技术社区  ›  Gregory Suvalian

如何将RegistrationKey传递给Azure DSC extenstion

  •  1
  • Gregory Suvalian  · 技术社区  · 6 年前

    我有下面的模板,在部署过程中出错,错误如下。文档页面上的示例似乎有误,甚至无法编译。

    “message”:“VM在处理扩展时报告了故障 'Microsoft。Powershell。DSC’。错误消息:\“DSC扩展失败 要安装:类型为的参数RegistrationKey的类型无效 PSCredential。\n有关故障的更多信息,请参阅 位于以下位置的日志 'C:\WindowsAzure\Logs\Plugins\Microsoft。Powershell。DSC\2.74.0.0' 在VM上。\要重试安装,请从VM中删除扩展 首先\"."

    样板

    {
      "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "resources": [
        {
          "name": "[parameters('swarmmanager1Name')]",
          "type": "Microsoft.Compute/virtualMachines",
          "location": "[resourceGroup().location]",
          "apiVersion": "2015-06-15",
          "tags": {
            "displayName": "swarmmanager1"
          },
          "properties": {
            "hardwareProfile": {
              "vmSize": "[parameters('swarmmanager1VmSize')]"
            },
            "licenseType": "[parameters('LicenseType')]",
            "osProfile": {
              "computerName": "[parameters('swarmmanager1Name')]",
              "adminUsername": "[parameters('adminUsername')]",
              "adminPassword": "[parameters('adminPassword')]"
            },
            "storageProfile": {
              "imageReference": {
                "publisher": "[parameters('swarmmanager1ImagePublisher')]",
                "offer": "[parameters('swarmmanager1ImageOffer')]",
                "sku": "[parameters('windowsOSVersion')]",
                "version": "latest"
              },
              "osDisk": {
                "name": "swarmmanager1OSDisk",
                "vhd": {
                  "uri": "[concat(reference(resourceId('Microsoft.Storage/storageAccounts', parameters('dockerswarmstorageaccountName')), '2016-01-01').primaryEndpoints.blob, parameters('swarmmanager1StorageAccountContainerName'), '/', parameters('swarmmanager1OSDiskName'), '.vhd')]"
                },
                "caching": "ReadWrite",
                "createOption": "FromImage"
              }
            },
    
            "networkProfile": {
              "networkInterfaces": [
                {
                  "id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('swarmmanager1NicName'))]"
                }
              ]
            }
          },
          "resources": [
            {
              "name": "Microsoft.Powershell.DSC",
              "type": "extensions",
              "location": "[resourceGroup().location]",
              "apiVersion": "2015-06-15",
              "dependsOn": [
                "[resourceId('Microsoft.Compute/virtualMachines', parameters('swarmmanager1Name'))]"
              ],
              "tags": {
                "displayName": "DSC"
              },
              "properties": {
                "publisher": "Microsoft.Powershell",
                "typeHandlerVersion": "2.26",
                "type":  "DSC",
                "autoUpgradeMinorVersion": true,
                "forceUpdateTag": "[parameters('DSCExtensionManagerTagVersion')]",
                "settings": {
                  "wmfVersion": "latest",
                  "configurationArguments": {
                    //"RegistrationKey": {
                    //     "UserName": "PLACEHOLDER_DONOTUSE",
                    //     "Password": "PrivateSettingsRef:registrationKeyPrivate"
                    //   },
                    "RegistrationKey": "[parameters('RegistrationKey')]",
                    "RegistrationUrl": "[parameters('registrationUrl')]",
                    "NodeConfigurationName": "SwarmManager.localhost",
                    "RebootNodeIfNeeded": true
    
    
                  }
                },
                "protectedSettings": {
                  "Items": {
                    "registrationKeyPrivate": "[parameters('RegistrationKey')]"
                  }
                }
    
    
              }
            }
              ]
            },
        {
          "name": "[parameters('dockerswarmstorageaccountName')]",
          "type": "Microsoft.Storage/storageAccounts",
          "location": "[resourceGroup().location]",
          "apiVersion": "2016-01-01",
          "sku": {
            "name": "[parameters('dockerswarmstorageaccountType')]"
          },
          "dependsOn": [],
          "tags": {
            "displayName": "dockerswarmstorageaccount"
          },
          "kind": "Storage"
        },
        {
          "name": "[parameters('swarmmanager1NicName')]",
          "type": "Microsoft.Network/networkInterfaces",
          "location": "[resourceGroup().location]",
          "apiVersion": "2016-03-30",
          "tags": {
            "displayName": "swarmmanager1Nic"
          },
          "properties": {
            "ipConfigurations": [
              {
                "name": "ipconfig1",
                "properties": {
                  "privateIPAllocationMethod": "Dynamic",
                  "subnet": {
                    "id": "[parameters('swarmmanager1SubnetRef')]"
                  },
                  "publicIPAddress": {
                    "id": "[resourceId('Microsoft.Network/publicIPAddresses', parameters('swarmmanagerpublicIPName'))]"
                  }
                }
              }
            ]
          }
        },
    
    
        {
          "apiVersion": "2016-03-30",
          "dependsOn": [],
          "location": "[resourceGroup().location]",
          "name": "[parameters('swarmmanagerpublicIPName')]",
          "properties": {
            "publicIPAllocationMethod": "Dynamic",
            "dnsSettings": {
              "domainNameLabel": "[parameters('swarmmanagerpublicIPDnsName')]"
            }
          },
          "tags": {
            "displayName": "swarmmanagerpublicIP"
          },
          "type": "Microsoft.Network/publicIPAddresses"
        }
      ],
      "parameters": {
        "swarmmanager1Name": { "type": "string" },
        "swarmmanager1VmSize": { "type": "string" },
        "adminUsername": { "type": "string" },
        "adminPassword": { "type": "securestring" },
        "dockerswarmstorageaccountName": { "type": "string" },
        "dockerswarmstorageaccountType": { "type": "string" },
        "swarmmanager1NicName": { "type": "string" },
        "swarmmanagerpublicIPName": { "type": "string" },
        "swarmmanager1SubnetRef": { "type": "string" },
        "swarmmanager1ImagePublisher": { "type": "string" },
        "swarmmanager1ImageOffer": { "type": "string" },
        "windowsOSVersion": { "type": "string" },
        "swarmmanager1StorageAccountContainerName": { "type": "string" },
        "swarmmanager1OSDiskName": { "type": "string" },
        "swarmmanagerpublicIPDnsName": { "type": "string" },
        "DSCConfigurationURL": { "type": "string" },
        "DSCExtensionManagerTagVersion": { "type": "string" },
        "RegistrationKey": { "type": "securestring" },
        "RegistrationUrl": { "type": "string" },
        "LicenseType": {"type": "string"}
    
      },
      "outputs": {
        "returnedIPAddress": {
          "type": "string",
          "value": "[reference(parameters('swarmmanager1NicName')).ipConfigurations[0].properties.privateIPAddress]"
        }
    
      }
    }
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   4c74356b41    6 年前

    如果要传入ps凭据,请执行以下操作:

            "protectedSettings": {
              "configurationArguments": {
                "RegistrationKey": {
                  "userName": "whatever",
                  "password": "[parameters('RegistrationKey')]"
                }
              }
            }