【问题标题】:"Pipeline Stopped" error while setting up Azure VM DSC Extension via Powershell通过 Powershell 设置 Azure VM DSC 扩展时出现“管道已停止”错误
【发布时间】:2016-12-29 09:07:50
【问题描述】:

PowerShell 版本:5

我已使用以下命令将 DSC ps1 文件以 zip 格式上传到 Azure 存储:

publish-azurermvmdscconfiguration

带有适当的参数和参数。然后我输入:

Set-AzureRmVmDSCExtension -ResourceGroupName Pollers -VmName <VmName> -ArchiveBlobName Run-DSCPython.zip -ArchiveStorageAccountName <storageAccountName> -Version 2.2 -Verbose

我在 PowerShell 中收到以下(通常是不透明的)错误消息:

Set-AzureRmVmDSCExtension : The pipeline has been stopped.
At line:1 char:1
+ Set-AzureRmVmDSCExtension -ResourceGroupName Pollers -VmName Download ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Set-AzureRmVMDscExtension], PipelineStoppedException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.Extension.DSC.SetAzureVMDscExtensionCommand

Set-AzureRmVmDSCExtension : Long running operation failed with status 'Failed'.
At line:1 char:1
+ Set-AzureRmVmDSCExtension -ResourceGroupName Pollers -VmName Download ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidResult: (:) [Set-AzureRmVMDscExtension], CloudException
    + FullyQualifiedErrorId : InvalidResult,Microsoft.Azure.Commands.Compute.Extension.DSC.SetAzureVMDscExtensionCommand

不过,在 Azure 门户中,我挖掘了一个更详细的日志,它很长,所以我将在这里只发布我认为与错误本身有关的部分:

 [ERROR] An error occurred while executing script or module 'Run-DSCPython':
  The specified module 'Run-DSCPython' was not loaded because no valid module file
 was found in any module directory.

知道我需要什么吗?它在寻找什么模块?

【问题讨论】:

  • 稍微更新了我的答案。
  • 模块是来自Run-DSCPython.zip 的模块...这应该是Run-DSCPython.ps1.zipRun-DSCPython.psm1.zip,具体取决于压缩包中包含的文件。如果您列出 zip 中的内容,我可以给出更好的答案。

标签: powershell azure module provisioning dsc


【解决方案1】:

虽然不能完全回答您的问题,但我建议您在 Azure 自动化中编译 mof 并将您的 VM 注册为 Azure 自动化的节点,这里写出来的过程有点冗长,我会写一个简短的指南:

# You can compile mof on your own PC and import, or compile in Azure Automation (preferred way)
<# 
 Import-AzureRmAutomationDscNodeConfiguration -Path "C:\localhost.mof" -ConfigurationName $configurationName `
   -ResourceGroupName $ResourceGroupName -AutomationAccountName $AutomationAccountName -Force
#>

$AutomationAccountName = "Automation"
$ResourceGroupName = "Azure"
$Location = "West Europe"
$VnetName = "VNet"

$configurationName = "Configuration-1"
$credName = "Name of credential asset in Azure Automation"
$nodeName = "localhost"
$StorageAccountName = "something"


# Import Configuration
$sourcePath = "C:\DSC.ps1"
Import-AzureRmAutomationDscConfiguration -SourcePath $sourcePath  `
   -ResourceGroupName $ResourceGroupName -AutomationAccountName $AutomationAccountName -Published -Force


# Compile mof
$ConfigurationData = @{ 
    AllNodes = @(
        @{
            NodeName = $nodeName
            PSDscAllowPlainTextPassword = $true
            RebootNodeIfNeeded = $true
            DebugMode = "All"
        }
    )
}

$Parameters = @{
    "storageAccountName" = $storageAccountName
    "nodeName" = $nodeName
    "credential" = $credName
}

Start-AzureRmAutomationDscCompilationJob -ResourceGroupName $ResourceGroupName -AutomationAccountName $AutomationAccountName `
    -ConfigurationName $configurationName -Parameters $Parameters -ConfigurationData $ConfigurationData 

# Register VM and apply mof
$VmName = "VM-Name";

Register-AzureRmAutomationDscNode -AutomationAccountName $AutomationAccountName -AzureVMName $VmName `
  -ResourceGroupName $ResourceGroupName -NodeConfigurationName "$configurationName.localhost"

编辑:忘了告诉你原因,我已经浪费了 2-3 周的时间来尝试让 DSC 扩展可靠地工作。我惨败了,另一方面,Azure 自动化要可靠得多,尽管一开始确实很棘手。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-15
    • 1970-01-01
    • 2017-02-02
    相关资源
    最近更新 更多