gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 23:57:34 26 4
gpt4 key购买 nike

我需要基于镜像创建VM(Windows Server 2016上的SQL Server 2016)并通过powershell向其添加DSC扩展。我有 template.json 及其在门户中创建VM(Windows 2016 服务器上的sql2016 服务器)时保存的parameters.json 文件(在参数文件中我定义了发布sdc zip 和管理员密码的url)。带有配置的 Zip 文件位于 github 公共(public)存储库中。它是由 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 有效,但我使用了另一个 - 同样的错误。部分parameters.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"
}

最佳答案

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

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

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

关于powershell - 无法在 ARM 模式下将 Azure DSC 扩展添加到 VM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40527459/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com