azure - Powershell 工作流运行手册 - 身份验证失败
问题描述
我有一个Azure 自动化 Run As account
。当我在 Azure 门户中的 Runbook 上运行以下代码(来自 Azure 在线教程的第 5 步)时,我收到如下所示的错误。问题:我可能在这里遗漏了什么,我们如何解决这个问题?
运行手册代码:
# 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 模块。
推荐阅读
- cmake - 我想知道如何使用 cmake 查找依赖项来编译最可爱的测试
- asp.net-core - 如何添加所有 Razor 页面都可以访问的功能?
- java - Java 类是用调试符号编译的,但堆栈跟踪中没有显示行号?
- angular - 如何使角度 mgl-timeline-entry 的开始扩展
- javascript - 无法在工具提示中显示格式化的 HTML
- excel - 在多列中搜索另一列中包含的文本,返回一个值
- java - java11中如何使用jdk.internal.misc.Signal
- google-cloud-platform - 云构建服务帐号权限构建
- javascript - 更改 vue.js 中不相关的属性后清除惰性模型的表单输入字段
- visual-studio - 在 VS2019 中将 ASP.NET Core Docker 映像从 x86 部署到 ARM (Raspberry Pi)