[英]Azure Runbook throwing error: Invoke-ProcessASDatabase
[英]Azure runbook GetMember Error
我有以下運行手冊腳本,該腳本應該將應用程序設置從一個Web應用程序復制到另一個Web應用程序,但是在運行它時出現錯誤。
# Get the credential to use for Authentication to Azure and Azure Subscription Name
$cred = Get-AutomationPSCredential -Name 'Credintial'
Login-AzureRmAccount -Credential $cred
$fromResourceGroup = 'parkprod'
$fromSite = 'parkprod'
$toResourceGroup = 'cmsfarhad'
$toSite = 'farhadparkingapi'
$props = (Invoke-AzureRmResourceAction -ResourceGroupName $fromResourceGroup -ResourceType Microsoft.Web/sites/Config -Name $fromSite/appsettings -Action list -ApiVersion 2015-08-01 -Force).Properties
$hash = @{}
$props | Get-Member -MemberType NoteProperty | % { $hash[$_.Name] = $props.($_.Name) }
Set-AzureRMWebApp -ResourceGroupName $toResourceGroup -Name $toSite -AppSettings $hash
錯誤:
Environments Context
------------ -------
{[AzureCloud, AzureCloud], [AzureChinaCloud, AzureChinaCloud], [AzureUSGovernment, AzureUSGovernment]} Microsoft.Azur...
Invoke-AzureRmResourceAction : Object reference not set to an instance of an object.
At line:10 char:11
+ $props = (Invoke-AzureRmResourceAction -ResourceGroupName $fromResour ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException
Get-Member : The input object cannot be bound to any parameters for the command either because the command does not
take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
At line:13 char:10
+ $props | Get-Member -InputObject $f -MemberType NoteProperty | % { $h ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-Member], ParameterBindingException
+ FullyQualifiedErrorId : InputObjectNotBound,Microsoft.PowerShell.Commands.GetMemberCommand
Get-Member : You must specify an object for the Get-Member cmdlet.
At line:13 char:10
+ $props | Get-Member -InputObject $f -MemberType NoteProperty | % { $h ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-Member], InvalidOperationException
+ FullyQualifiedErrorId : NoObjectInGetMember,Microsoft.PowerShell.Commands.GetMemberCommand
Set-AzureRMWebApp : The term 'Set-AzureRMWebApp' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:15 char:1
+ Set-AzureRMWebApp -ResourceGroupName $toResourceGroup -Name $toSite - ...
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-AzureRMWebApp:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
您必須安裝AzureRm.Websites 。 該模塊缺少cmdlet。 檢查是否已將其安裝在系統上,如果尚未安裝,請檢查。
如Peter所說,AzureRM.Websites PowerShell模塊當前未包含在自動化服務中,因此您需要自己導入此模塊。 請參閱https://azure.microsoft.com/zh-cn/blog/announcing-azure-resource-manager-support-azure-automation-runbooks/了解更多詳細信息。
但是,看起來您在使用Invoke-AzureRmResourceAction cmdlet時也遇到了問題。 返回的錯誤不是很有用,並且我對該cmdlet不太熟悉,所以很難說出您在做什么錯。 要測試的一件事是檢查從本地PowerShell是否可以執行相同的cmdlet調用。 如果它在本地PowerShell中不起作用,則問題出在您的代碼上,而不是Azure Automation中的任何問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.