无法在ARM模式下将Azure DSC扩展添加到VM

时间:2016-11-10 12:18:45

标签: powershell azure azure-resource-manager dsc

我需要基于图像创建VM(Windows Server 2016上的SQL Server 2016)并通过powershell为其添加DSC扩展。我有template.json和我在门户中创建VM(Windows 2016服务器上的sql2016服务器)时保存的parameters.json文件(在参数文件中我定义了url,其中发布了sdc zip和admin密码)。 带有配置的Zip文件位于github公共存储库中。它是由powershell发布的命令行开关创建的。 在此之后我的下一步是:

Login-AzureRmAccount
# Create resource group
New-AzureRmResourceGroup -Name orsql1 -Location 'North Europe' # succeed

# Define deployment variables
$Deployment = @{
    ResourceGroupName = 'orsqllast';
    Mode = 'Complete';
    TemplateFile = 'template.json';
    TemplateParameterFile = 'parameters.json';
    Force = $true;
}
New-AzureRmResourceGroupDeployment @Deployment  -DeploymentDebugLogLevel All

dsc1.ps1内容:

configuration IISInstall
{
    node ("localhost")
    {
        WindowsFeature IIS
        {
            Ensure = "Present"
            Name = "Web-Server"
        }
    }
}

很长一段时间后我都遇到了这个错误:

New-AzureRmResourceGroupDeployment : 14:02:10 - Resource Microsoft.Resources/deployments 'Microsoft.DSC-20161
010122604' failed with message '{
  "status": "Failed",
  "error": {
    "code": "ResourceDeploymentFailure",
    "message": "The resource operation completed with terminal provisioning state 'Failed'.",
    "details": [
      {
        "code": "DeploymentFailed",
        "message": "At least one resource deployment operation failed. Please list deployment operations for 
details. Please see https://aka.ms/arm-debug for usage details.",
        "details": [
          {
            "code": "Conflict",
            "message": "{\r\n  \"status\": \"Failed\",\r\n  \"error\": {\r\n    \"code\": \"ResourceDeploymen
tFailure\",\r\n    \"message\": \"The resource operation completed with terminal provisioning state 'Failed'.
\",\r\n    \"details\": [\r\n      {\r\n        \"code\": \"VMExtensionProvisioningError\",\r\n        \"mess
age\": \"VM has reported a failure when processing extension 'Microsoft.Powershell.DSC'. Error message: \\\"E
rror unpacking 'dsc1.ps1.zip'; verify this is a valid ZIP package.\\nError details: Exception calling \\\"Ext
ractToDirectory\\\" with \\\"2\\\" argument(s): \\\"End of Central Directory record could not be found.\\\"\\
\".\"\r\n      }\r\n    ]\r\n  }\r\n}"
          }
        ]
      }
    ]
  }
}'
At line:14 char:1
+ New-AzureRmResourceGroupDeployment @Deployment  -DeploymentDebugLogLe ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResour 
   ceGroupDeploymentCmdlet

New-AzureRmResourceGroupDeployment : 14:02:10 - At least one resource deployment operation failed. Please lis
t deployment operations for details. Please see https://aka.ms/arm-debug for usage details.
At line:14 char:1
+ New-AzureRmResourceGroupDeployment @Deployment  -DeploymentDebugLogLe ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResour 
   ceGroupDeploymentCmdlet

New-AzureRmResourceGroupDeployment : 14:02:10 - Template output evaluation skipped: at least one resource dep
loyment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug 
for usage details.
At line:14 char:1
+ New-AzureRmResourceGroupDeployment @Deployment  -DeploymentDebugLogLe ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResour 
   ceGroupDeploymentCmdlet

New-AzureRmResourceGroupDeployment : 14:02:10 - Template output evaluation skipped: at least one resource dep
loyment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug 
for usage details.
At line:14 char:1
+ New-AzureRmResourceGroupDeployment @Deployment  -DeploymentDebugLogLe ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResour 
   ceGroupDeploymentCmdlet

zip是有效的,我使用另一个 - 同样的错误。 参数的一部分.json

"ex0_vmName": {
"value": "node1"
},
"ex0_location": {
"value": "northeurope"
},
"ex0_modulesUrl": {
"value": "https://github.com/myname/mydsc/blob/master/dsc1.ps1.zip"
},
"ex0_configurationFunction": {
"value": "dsc1.ps1\\IISInstall"
},
"ex0_wmfVersion": {
"value": "latest"
},
"ex0_privacy": {
"value": "Enable"
},
"ex0_version": {
"value": "2.8"
}

1 个答案:

答案 0 :(得分:1)

我建议您在c:\ windowsazure \ logs中查询VM本身的日志。在c:\ extensions(现在是C:\ Packages \ Plugins)下,您可以找到您的zip包和DSC扩展文件。

解决问题的最简单方法是使用门户创建DSC扩展。如果失败并出现相同的错误,则需要重新创建zip文件。我在zip包中遇到了同样的错误,并通过重新创建它来解决它们。

我还建议您转到Azure自动化。根据您的范围,您可能每月有500分钟的免费分钟,您可以将自己的上传到Azure自动化。而且我发现Azure自动化比DSC扩展更加一致。