"Pipeline Stopped" 通过 Powershell 设置 Azure VM DSC 扩展时出错
"Pipeline Stopped" error while setting up Azure VM DSC Extension via Powershell
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 门户中,我挖掘了一个更详细的日志,它很长,所以我 post 这里只列出我认为与错误本身有关的部分:
[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.
知道我需要什么吗?它在寻找什么模块?
虽然不能完全回答你的问题,但我建议你在 Azure Automation 中编译 mofs 并将你的 VM 作为节点注册到 Azure Automation,这个过程写在这里有点冗长,我会写一个简短的指南:
# 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 自动化要可靠得多,尽管一开始真的很棘手。
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 门户中,我挖掘了一个更详细的日志,它很长,所以我 post 这里只列出我认为与错误本身有关的部分:
[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.
知道我需要什么吗?它在寻找什么模块?
虽然不能完全回答你的问题,但我建议你在 Azure Automation 中编译 mofs 并将你的 VM 作为节点注册到 Azure Automation,这个过程写在这里有点冗长,我会写一个简短的指南:
# 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 自动化要可靠得多,尽管一开始真的很棘手。