【发布时间】:2016-08-19 14:59:13
【问题描述】:
我正在为 Azure 中的基础架构创建编写一个自动化脚本,其中包含以下代码:
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
最后一行(Publish-AzureVMDscConfiguration)抛出错误:
Publish-AzureVMDscConfiguration:对象引用未设置为 对象的实例。在 C:\temp\Base.Deploy\ARM.Create.ps1:38 char:5 + 发布-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..
标签: powershell azure azure-blob-storage