I constructed a new Azure Pipeline and added this 'Azure CLI' task to try and run some Azure CLI Powershell scripting. Primarily, I want to do some checks on an existing AppInsights resources. (Azure CLI) https://github.com/microsoft/azure-pipelines-tasks/blob/master/Tasks/AzureCLIV2/Readme.md
I get this error when runnin 'Get-AzApplicationInsights' inside the Azure CLI Task.
'Get-AzApplicationInsights' : The term 'Get-AzApplicationInsights' is not recognized as the name of a cmdlet, function.
The whole yaml script looks like this:
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"
Is there something I am missing as to why the cmdlet is not being recognised? Should there be a module I need to first to import?
To run the Azure powershell Get-AzApplicationInsights
, just run it in the Azure PowerShell task.
Or if you want to use the Azure CLI task, you could use CLI command az monitor app-insights component show
directly instead of the powershell command.