Azure devops 无法识别Get-AzApplicationInsights

Azure devops 无法识别Get-AzApplicationInsights,azure-devops,azure-pipelines,azure-cli,azure-yaml-pipelines,Azure Devops,Azure Pipelines,Azure Cli,Azure Yaml Pipelines,我构建了一个新的Azure管道,并添加了这个“Azure CLI”任务,以尝试运行一些Azure CLI Powershell脚本。首先,我想对现有的AppInsights资源进行一些检查。 (Azure CLI) 我在Azure CLI任务中运行“获取AzApplicationInsights”时遇到此错误 'Get-AzApplicationInsights' : The term 'Get-AzApplicationInsights' is not recognized as the n

我构建了一个新的Azure管道,并添加了这个“Azure CLI”任务,以尝试运行一些Azure CLI Powershell脚本。首先,我想对现有的AppInsights资源进行一些检查。 (Azure CLI)

我在Azure CLI任务中运行“获取AzApplicationInsights”时遇到此错误

'Get-AzApplicationInsights' : The term 'Get-AzApplicationInsights' is not recognized as the name of a cmdlet, function.
整个yaml脚本如下所示:

steps:
- task: AzureCLI@2
  displayName: 'Azure CLI Powershell'
  inputs:
    azureSubscription: ####
    scriptType: ps
    scriptLocation: inlineScript
    inlineScript: |
     Write-Output "RESULTS:"
     az config set extension.use_dynamic_install=yes_without_prompt
     Get-AzApplicationInsights -ResourceGroupName ############# -Name ############## Select-String -Pattern "PricingPlan"

我是否遗漏了无法识别cmdlet的原因?是否需要先导入模块?

要运行Azure powershell
获取AzApplicationInsights
,只需在中运行它


或者,如果要使用Azure CLI任务,可以直接使用CLI命令而不是powershell命令。

要运行Azure powershell
获取AzApplicationInsights
,只需在中运行它

或者,如果您想使用Azure CLI任务,可以直接使用CLI命令而不是powershell命令。

同意Joy Wang的观点

选中此选项,
Get-AzApplicationInsights
是power shell CMD安装还是Azure CLI,我们应该通过任务Azure power shell而不是Azure CLI任务来运行它

生成定义示例:

- task: AzurePowerShell@5
  displayName: 'Azure PowerShell script: InlineScript'
  inputs:
    azureSubscription: '{Subscription}'
    ScriptType: InlineScript
    Inline: 'Get-AzApplicationInsights -ResourceGroupName "{Resource Group Name}" -Name "{Application Insights name}" -IncludePricingPlan'
    azurePowerShellVersion: LatestVersion
结果:

同意Joy Wang的观点

选中此选项,
Get-AzApplicationInsights
是power shell CMD安装还是Azure CLI,我们应该通过任务Azure power shell而不是Azure CLI任务来运行它

生成定义示例:

- task: AzurePowerShell@5
  displayName: 'Azure PowerShell script: InlineScript'
  inputs:
    azureSubscription: '{Subscription}'
    ScriptType: InlineScript
    Inline: 'Get-AzApplicationInsights -ResourceGroupName "{Resource Group Name}" -Name "{Application Insights name}" -IncludePricingPlan'
    azurePowerShellVersion: LatestVersion
结果:


您好,如果这个答案有帮助,您是否愿意接受它作为答案?因此,它可以帮助其他社区成员谁得到同样的问题,我们可以存档此线程。谢谢祝你今天愉快。:)嗨,如果这个答案有帮助,你能接受它作为答案吗?因此,它可以帮助其他社区成员谁得到同样的问题,我们可以存档此线程。谢谢祝你今天愉快。:)谢谢陛下,问题解决了。谢谢陛下,问题解决了。