1
votes

I'm trying to create an Application Insights resource following the directions provided here: https://docs.microsoft.com/en-us/azure/azure-monitor/app/powershell

However, when I execute the command from the docs:

New-AzResourceGroupDeployment -ResourceGroupName Fabrikam -TemplateFile .\template1.json -appName myNewApp

Replacing Fabrikam my Resource Group Name, it throws ResourceGroupNotFound. If I list the Resource Groups with:

az group list

I can clearly see the Resource Group in the list, so I know I'm in the right subscription context.

Any thing obvious that I'm missing?

I've uploaded my version of template1.json already to the CLI storage.

1

1 Answers

3
votes

I can clearly see the Resource Group in the list, so I know I'm in the right subscription context.

No, if you can use az group list to see the group, it just means the azure CLI context is in the right subscription. The New-AzResourceGroupDeployment is azure powershell, they are different, you need to use Get-AzResourceGroup to list groups.

To check if you are in the correct subscription, just use Get-AzContext. If you want to set the subscription for the powershell context, just use Set-AzContext -Subscription "<subscription-id>".

I've uploaded my version of template1.json already to the CLI storage.

I suppose you mean you upload the template to the azure storage. If so, you could not use this parameter -TemplateFile, you need to use -TemplateUri and -TemplateParameterUri, you need to generate the SAS urls for your template files(if your container is not public), then specify the two parameters, see this link.


Actually, you can use New-AzResource to create the app insight directly, no need to use the template in the doc.

Sample:

New-AzResource -ResourceName "<appinsight-name>" -ResourceGroupName <resourcegroup-name> -ResourceType "Microsoft.Insights/components" -Location "East US" -PropertyObject @{"Application_Type"="web"}

enter image description here