Azure Powershell Runbook - Get-AzureRMWebAppSlot SiteConfig.ConnectionStrings[0] 错误无法索引到空数组
Azure Powershell Runbook - Get-AzureRMWebAppSlot SiteConfig.ConnectionStrings[0] erroring cannot index into a null array
我正在尝试在 PowerShell Workflow Runbook 中执行以下命令。我收到错误 "cannot index into a null array.",这是不正确的,因为 运行 在我的本地计算机上完美运行的同一脚本在 Azure 门户中作为 PowerShell 工作流运行手册没有执行。
任何人都可以调查一下吗?
$webApp = Get-AzureRMWebAppSlot -ResourceGroupName $ResourceGroupName -Name $WebSiteName -Slot $WebSiteSlot
$webApp
"Printing Website ConncectionString"
$webApp.SiteConfig.ConnectionStrings.ConnectionString[0]
某些类型 serialize/deserialize 不正确,在 PowerShell Workflow 中这是一个问题,因为 PowerShell Workflow 依赖于对象 serialization/deserialization(这就是 PSWF 能够检查点、暂停和恢复的方式——它在 checkpointing/suspending 时将所有对象转换为字符串形式,并在恢复时从这些字符串恢复为完整对象。
Get-AzureRMWebAppSlot
的输出对象似乎是 serialize/deserialize 不正确的类型之一。从您的屏幕截图中,我可以看到 $webApp
的 SiteConfig
属性 是一个包含 Microsoft.Azure.Management.WebSites.Model.SiteConfig
的字符串,而不是您期望的对象。显然,该对象没有正确反序列化回其原始形式,其中 SiteConfig
是一个复杂对象。
解决此问题的方法是仅与 PowerShell 脚本上下文中的对象交互,而不是工作流上下文中的对象。例如:
workflow foo {
$ResourceGroupName = "RG"
$WebSiteName = "WS"
$WebSiteSlot = "Slot"
$ConnectionString = InlineScript {
$webApp = Get-AzureRMWebAppSlot -ResourceGroupName $using:ResourceGroupName -Name $using:WebSiteName -Slot $using:WebSiteSlot
$webApp.SiteConfig.ConnectionStrings.ConnectionString[0]
}
"Printing Website ConnectionString"
$ConnectionString
}
我正在尝试在 PowerShell Workflow Runbook 中执行以下命令。我收到错误 "cannot index into a null array.",这是不正确的,因为 运行 在我的本地计算机上完美运行的同一脚本在 Azure 门户中作为 PowerShell 工作流运行手册没有执行。
任何人都可以调查一下吗?
$webApp = Get-AzureRMWebAppSlot -ResourceGroupName $ResourceGroupName -Name $WebSiteName -Slot $WebSiteSlot
$webApp
"Printing Website ConncectionString"
$webApp.SiteConfig.ConnectionStrings.ConnectionString[0]
某些类型 serialize/deserialize 不正确,在 PowerShell Workflow 中这是一个问题,因为 PowerShell Workflow 依赖于对象 serialization/deserialization(这就是 PSWF 能够检查点、暂停和恢复的方式——它在 checkpointing/suspending 时将所有对象转换为字符串形式,并在恢复时从这些字符串恢复为完整对象。
Get-AzureRMWebAppSlot
的输出对象似乎是 serialize/deserialize 不正确的类型之一。从您的屏幕截图中,我可以看到 $webApp
的 SiteConfig
属性 是一个包含 Microsoft.Azure.Management.WebSites.Model.SiteConfig
的字符串,而不是您期望的对象。显然,该对象没有正确反序列化回其原始形式,其中 SiteConfig
是一个复杂对象。
解决此问题的方法是仅与 PowerShell 脚本上下文中的对象交互,而不是工作流上下文中的对象。例如:
workflow foo {
$ResourceGroupName = "RG"
$WebSiteName = "WS"
$WebSiteSlot = "Slot"
$ConnectionString = InlineScript {
$webApp = Get-AzureRMWebAppSlot -ResourceGroupName $using:ResourceGroupName -Name $using:WebSiteName -Slot $using:WebSiteSlot
$webApp.SiteConfig.ConnectionStrings.ConnectionString[0]
}
"Printing Website ConnectionString"
$ConnectionString
}