【问题标题】:Cannot start Azure stream analytics from azure automation run book?无法从 azure 自动化运行手册启动 Azure 流分析?
【发布时间】:2020-01-18 05:57:24
【问题描述】:

当我尝试从 azure 自动化的 power 或 power shell Runbook 启动 Azure 流分析时

这里是我用来启动power shell的代码

Start-AzStreamAnalyticsJob -ResourceGroupName 'RealTimeAnalytics' -Name 'SQLCDCProcessor'

这是我在运行手册中使用的代码。

$ServicePrincipalConnection = Get-AutomationConnection -Name "AzureRunAsConnection"
Connect-AzureRmAccount `
    -ServicePrincipal `
    -TenantId $ServicePrincipalConnection.TenantId `
    -ApplicationId $ServicePrincipalConnection.ApplicationId `
    -CertificateThumbprint $ServicePrincipalConnection.CertificateThumbprint | Write-Verbose
Start-AzStreamAnalyticsJob -Name SQLCDCProcessor -ResourceGroupName RealTimeAnalytics

当我运行时,只有以下代码

 Start-AzStreamAnalyticsJob -Name SQLCDCProcessor -ResourceGroupName RealTimeAnalytics

我的结果是假的

但是当我运行所有代码行时,我收到以下错误。

Start-AzStreamAnalyticsJob : The 'Start-AzStreamAnalyticsJob' command was found in the module 'Az.StreamAnalytics', but the module could not be loaded

【问题讨论】:

    标签: azure powershell azure-powershell azure-stream-analytics azure-automation


    【解决方案1】:

    问题应该是你没有安装Az.StreamAnalytics powershell 模块。

    在门户中导航到您的自动化帐户 -> Modules -> Browse Gallery -> 搜索 Az.StreamAnalytics 模块 -> Import。导入完成后再试,应该可以正常使用了。

    更新

    在你的脚本中,你使用旧的 AzureRm 命令Connect-AzureRmAccount,你需要使用Connect-AzAccount,还要确保你已经导入了Az.Accounts 模块。

    该示例对我有用:

    $servicePrincipalConnection=Get-AutomationConnection -Name "AzureRunAsConnection"         
    
    Connect-AzAccount `
            -ServicePrincipal `
            -TenantId $servicePrincipalConnection.TenantId `
            -ApplicationId $servicePrincipalConnection.ApplicationId `
            -CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint | Write-Verbose
    
    Start-AzStreamAnalyticsJob -Name "<jobname>" -ResourceGroupName "<ResourceGroupName>"
    

    【讨论】:

      【解决方案2】:

      Azure PowerShell 不支持某些 IoT 中心操作,必须使用 Azure CLI 2.0.24 或更高版本以及 Azure CLI 的 IoT 扩展来完成。

      安装 Azure CLI 并使用 az extension add --name azure-cli-iot-ext 安装 IoT 扩展。

      【讨论】:

      • 我已经更新了我的代码并安装了模块我仍然收到一些其他错误
      猜你喜欢
      • 1970-01-01
      • 2021-12-21
      • 1970-01-01
      • 2022-10-21
      • 2016-06-17
      • 2019-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多