通过Powershell设置Azure VM DSC扩展时出现“管道已停止”错误

时间:2016-12-29 09:07:51

标签: powershell azure module provisioning dsc

PowerShell版本:5

我已使用以下命令将zip ps的DSC ps1文件上传到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.

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

1 个答案:

答案 0 :(得分:1)

虽然不完全是对您的问题的答案,但我建议您在Azure自动化中编译mofs并将您的VM注册为Azure自动化的节点,这个过程有点冗长,在此处写出来,我&#39;我会写一个简短的指南:

# 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扩展工作RELIABLY。我失败了,另一方面,Azure Automation更可靠,虽然开始时非常棘手。