0

我正在尝试将Azure资源模板部署到Azure上的全新Windows Server VM,其中包括一个Microsoft.Powershell.DSC资源给VM。处理扩展错误'Microsoft.Powershell.DSC'

DSC配置文件已被推送到公共可访问的Azure存储Blob容器,我已验证可以从访问URL的浏览器下载。

成功部署新VM后,我添加了一个扩展子资源来执行存储在上述Azure blob容器中的DSC配置文件。

我不明白为什么它失败。

我使用这个命令执行部署:

New-AzureRmResourceGroupDeployment ` 
    -Name $resourceDeploymentName ` 
    -ResourceGroupName $rscrcGrpName ` 
    -TemplateFile $templatePath ` 
    -TemplateParameterFile $parameterPath ` 
    -Verbose 

以下是错误:

New-AzureRmResourceGroupDeployment : 3:56:46 PM - Resource Microsoft.Compute/virtualMachines 'DC1' failed with message '{ 
    "status": "Failed", 
    "error": { 
    "code": "ResourceDeploymentFailure", 
    "message": "The resource operation completed with terminal provisioning state 'Failed'.", 
    "details": [ 
     { 
     "code": "VMExtensionProvisioningError", 
     "message": "VM has reported a failure when processing extension 'Microsoft.Powershell.DSC'. Error message: \"The DSC Extension failed to install: 
Error unpacking 'DomainController-DSC.ps1'; verify this is a valid ZIP package.\nError details: Exception calling \"ExtractToDirectory\" with \"2\" 
argument(s): \"End of Central Directory record could not be found.\".\r\nMore information about the failure can be found in the logs located under 
'C:\\WindowsAzure\\Logs\\Plugins\\Microsoft.Powershell.DSC\\2.20.0.0' on the VM.\r\nTo retry install, please remove the extension from the VM first. \"." 
     } 
    ] 
    } 
}' 
At line:1 char:1 
+ New-AzureRmResourceGroupDeployment ` 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception 
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet 

New-AzureRmResourceGroupDeployment : 3:56:46 PM - VM has reported a failure when processing extension 'Microsoft.Powershell.DSC'. Error message: "The DSC 
Extension failed to install: Error unpacking 'DomainController-DSC.ps1'; verify this is a valid ZIP package. 
Error details: Exception calling "ExtractToDirectory" with "2" argument(s): "End of Central Directory record could not be found.". 
More information about the failure can be found in the logs located under 'C:\WindowsAzure\Logs\Plugins\Microsoft.Powershell.DSC\2.20.0.0' on the VM. 
To retry install, please remove the extension from the VM first. ". 
At line:1 char:1 
+ New-AzureRmResourceGroupDeployment ` 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception 
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet 

New-AzureRmResourceGroupDeployment : 3:56:46 PM - Template output evaluation skipped: at least one resource deployment operation failed. Please list 
deployment operations for details. Please see https://aka.ms/arm-debug for usage details. 
At line:1 char:1 
+ New-AzureRmResourceGroupDeployment ` 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception 
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet 

New-AzureRmResourceGroupDeployment : 3:56:46 PM - Template output evaluation skipped: at least one resource deployment operation failed. Please list 
deployment operations for details. Please see https://aka.ms/arm-debug for usage details. 
At line:1 char:1 
+ New-AzureRmResourceGroupDeployment ` 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception 
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet 

这里是VM资源定义:

{ 
     "name": "[parameters('virtualMachineName')]", 
     "type": "Microsoft.Compute/virtualMachines", 
     "apiVersion": "2015-06-15", 
     "location": "[parameters('location')]", 
     "tags": { 
     "displayName": "vm-DC1" 
     }, 
     "dependsOn": [ 
     "[concat('Microsoft.Network/networkInterfaces/', parameters('networkInterfaceName'))]", 
     "[concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]", 
     "[concat('Microsoft.Storage/storageAccounts/', parameters('diagnosticsStorageAccountName'))]" 
     ], 
     "properties": { 
     "osProfile": { 
      "computerName": "[parameters('virtualMachineName')]", 
      "adminUsername": "[parameters('vmAdminUsername')]", 
      "adminPassword": "[parameters('vmAdminPassword')]", 
      "windowsConfiguration": { 
      "provisionVmAgent": "true" 
      } 
     }, 
     "hardwareProfile": { 
      "vmSize": "[parameters('virtualMachineSize')]" 
     }, 
     "storageProfile": { 
      "imageReference": { 
      "publisher": "MicrosoftWindowsServer", 
      "offer": "WindowsServer", 
      "sku": "2012-R2-Datacenter", 
      "version": "latest" 
      }, 
      "osDisk": { 
      "name": "[parameters('virtualMachineName')]", 
      "vhd": { 
       "uri": "[concat(concat(reference(resourceId(resourceGroup().name, 'Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2015-06-15').primaryEndpoints['blob'], 'vhds/'), parameters('virtualMachineName'), '2016812162929.vhd')]" 
      }, 
      "createOption": "fromImage" 
      }, 
      "dataDisks": [ ] 
     }, 
     "networkProfile": { 
      "networkInterfaces": [ 
      { 
       "id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaceName'))]" 
      } 
      ] 
     }, 
     "diagnosticsProfile": { 
      "bootDiagnostics": { 
      "enabled": true, 
      "storageUri": "[reference(resourceId(resourceGroup().name, 'Microsoft.Storage/storageAccounts', parameters('diagnosticsStorageAccountName')), '2015-06-15').primaryEndpoints['blob']]" 
      } 
     } 
     }, 
     "resources": [ 
     { 
      "name": "Microsoft.Powershell.DSC", 
      "type": "extensions", 
      "location": "[parameters('location')]", 
      "apiVersion": "2015-06-15", 
      "dependsOn": [ 
      "[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]" 
      ], 
      "tags": { 
      "displayName": "dsc-DomainController" 
      }, 
      "properties": { 
      "publisher": "Microsoft.Powershell", 
      "type": "DSC", 
      "typeHandlerVersion": "2.9", 
      "autoUpgradeMinorVersion": true, 
      "forceUpdateTag": "1.0", 
      "settings": { 
       "configuration": { 
       "url": "https://armstore0.blob.core.windows.net/dsc/DomainController-DSC.ps1.zip", 
       "script": "DomainController-DSC.ps1", 
       "function": "FileResourceDemo" 
       }, 
       "configurationArguments": { 
       "nodeName": "[parameters('virtualMachineName')]" 
       } 

      } 
      } 
     } 
     ] 
    } 
+0

不确定这是相关的,但您的模板传递给脚本不接受的configArg。尝试删除它,看看它是否有帮助。此外,这里有一个“hello world”示例可能有所帮助:https://github.com/bmoore-msft/AzureRM-Samples/tree/master/VMDSCInstallFile –

回答

0

这可能是一些网络毛刺。你有没有尝试再次部署模板?

+0

不太可能。感谢你的想法。我已经重新部署了很多次。 – ChiliYago

+0

版本2.20的扩展使用以下代码来提取压缩文件。您可以在您看到此问题的计算机上的zip文件上手动运行此代码:Add-Type -assemblyname System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile] :: ExtractToDirectory($ configurationPackageFullName,$ WorkingDirectory ) –

+0

谢谢我通过从Azure blob存储下载我的zip然后运行,尝试了您的代码。按预期提取文件。它一定是别的东西。 – ChiliYago