我写的基础设施建立在Azure的自动化脚本包含以下代码:Azure中的PowerShell - 发布 - AzureVMDscConfiguration:抛出对象未设置错误
Azure-LoginAndPickSubscription -azureSubscriptionId $CONFIG_AZURE["SUBSCRIPTIONID"] `
-azureUsername $CONFIG_AZURE["USERNAME"] `
-azureEncryptedPassword $CONFIG_AZURE["PASSWORD"] `
-passwordKeyFilePath "$SCRIPT_DIRECTORY\private.key"
$solutionRoot = Split-Path -Path $SCRIPT_DIRECTORY -Parent
$storContext = (New-AzureStorageContext -StorageAccountName mystorename -StorageAccountKey "mystoragekey")
Publish-AzureVMDscConfiguration "$SCRIPT_DIRECTORY\NewDSC\InitialConfig.ps1" -ContainerName "windows-powershell-dsc" -Force -StorageContext $storContext
最后一行(发布-AzureVMDscConfiguration)抛出一个错误:
Publish-AzureVMDscConfiguration : Object reference not set to an instance of an object. At C:\temp\Base.Deploy\ARM.Create.ps1:38 char:5 + Publish-AzureVMDscConfiguration "$SCRIPT_DIRECTORY\NewDSC\Initia ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Publish-AzureVMDscConfiguration], NullReferenceException + FullyQualifiedErrorId : System.NullReferenceException,Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.Extensions.DSC.PublishAzureVMDscConfigurationCommand
我已经检查了脚本(InitialConfig.ps1)存在,并填充$ storContext对象。任何想法可能造成这种情况?
很难说为什么会失败。 InitialConfig.ps1可能不正确。你能在这里发表剧本吗?将有助于更好地诊断此问题。 –
嗨@ Rena-MSFT,感谢评论 - 我已经运行此与没有问题在一个不同的服务器上安装的旧版本的cmdlet(1.1.5) - 所以我猜这可能是与问题服务器上使用的新cmdlet版本(2.0.1)。我也可以在问题服务器上运行'Publish-AzureVMDscConfiguration“$ SCRIPT_DIRECTORY \ NewDSC \ InitialConfig.ps1”-ConfigurationArchivePath“C:\ temp \ dsc \ MyConfig.zip”-Force'。 – Carl