AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 840393
Accepted
Larry Silverman
Larry Silverman
Asked: 2017-03-25 05:22:56 +0800 CST2017-03-25 05:22:56 +0800 CST 2017-03-25 05:22:56 +0800 CST

Azure 自动化中的 Get-AutomationPSCredential 间歇性失败

  • 772

每隔一段时间,我们就会发现 Azure 自动化 Runbook 失败并出现以下错误:

Get-AutomationPSCredential : The term 'Get-AutomationPSCredential' 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:1 char:9
+ $cred = Get-AutomationPSCredential -Name SqlJobRunner
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-AutomationPSCredential:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

我们的不同运行手册似乎随机出现此错误。

Get-AutomationPSCredential是 Azure 提供的模块。这不是我们的代码,而是微软的。

有时,它似乎只是“走开”。

那么这里发生了什么?Azure 自动化基础设施是否在不合时宜的时间重新加载或更新模块?我的印象是,一旦安排了 Runbook,相关模块就会“绑定”到 Runbook,因此它们会在需要时出现。

为什么会发生这种情况,防止失败的最佳方法是什么?

powershell
  • 2 2 个回答
  • 4224 Views

2 个回答

  • Voted
  1. Best Answer
    Larry Silverman
    2017-04-14T10:13:44+08:002017-04-14T10:13:44+08:00

    我接到了来自 Microsoft Azure 支持的电话,询问了根本原因。

    我所在地区(美国东部)的 Azure 自动化在 PowerShell 5.0 上运行。他们说 5.0 中存在模块异步加载的问题。因此,不能保证跨模块依赖项可用。

    他们告诉我这个缺陷将在 8 月份向美国东部地区发布 PowerShell 5.1 时修复。

    他们提供了两种缓解措施:

    1. 在 try/catch 循环中执行 Get-AutomationPSCredential,在重试之间休眠 30 秒。
    2. 使用混合工作器将工作分配到安装了 PowerShell 5.1 的 VM。

    另一个缓解措施是在我需要的地方导入所需的模块。这样做的一个复杂之处在于,所讨论的函数 Get-AutomationPSCredential 来自本地开发中的不同程序集,而不是在自动化上下文中执行时。在使用 Azure 自动化创作工具包进行本地开发时,该命令位于 assembly 中AzureAutomationAuthoringToolkit。在 Azure 中,它位于Orchestrator.AssetManagement.Cmdlets.

    我将简单地尝试这个: Import-Module Orchestrator.AssetManagement.Cmdlets -ErrorAction SilentlyContinue

    在 ISE 环境中执行时,该函数将始终存在,并且此 Import-Module 将静默失败。

    • 1
  2. Jason Ye
    2017-03-27T20:08:46+08:002017-03-27T20:08:46+08:00

    根据您的描述,我们应该检查模块是否有导入。如果没有,我们应该导入它。

    我们可以使用门户网站来检查它:

    自动化帐户-> 模块-> Orchestrator.AssetManagement.Cmdlets: 在此处输入图像描述

    如果我们不导入它,我们应该使用门户来导入这个模块:

    在此处输入图像描述

    在此处输入图像描述

    • 0

相关问题

  • 资源锁和电源外壳

  • 脚本 - 如何断开远程桌面会话?

  • 如何限制向通讯组发送到外部地址?

  • Powershell对值与数组的作用不同?

  • Windows Powershell Vim 键绑定

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve