我有一个Azure自动化 Run As account
。当我在Azure Portal中的运行本上运行以下代码(来自Azure在线教程的第5步)时,出现以下错误。问题:我在这里可能会缺少什么,我们如何解决该问题?
Runbook代码:
# Ensures you do not inherit an AzContext in your runbook
Disable-AzContextAutosave –Scope Process
$Conn = Get-AutomationConnection -Name AzureRunAsConnection
Connect-AzAccount -ServicePrincipal -Tenant $Conn.TenantID `
-ApplicationId $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint
$AzureContext = Select-AzSubscription -SubscriptionId $Conn.SubscriptionID
错误:
Failed At line:4 char:1
+ Disable-AzContextAutosave –Scope Process
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Cannot find the 'Disable-AzContextAutosave' command. If this command is defined as a workflow, ensure it is defined before the workflow that calls it. If it is a command intended to run directly within Windows PowerShell (or is not available on this system), place it in an InlineScript: 'InlineScript { Disable-AzContextAutosave }'
我假设您尚未将Az.Accounts
模块导入您的自动化帐户。Disable-AzContextAutosave
,Connect-AzAccount
并且Select-AzSubscription
来自此模块。
请遵循本指南来导入Az模块。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句