question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Functionapp:az functionapp create fails to create and configure Application Insights for function app in new regions

See original GitHub issue

Describe the bug When trying to create a Linux Consumption Function App in Jio India West and US West 3 regions (these are new regions), we get the following error:

PS C:\Users\pagombar> az functionapp create --name pagombar-usw3-cli --resource-group pagombar --storage-account pagombarusw3 --os-type Linux --runtime dotnet --consumption-plan-location westus3
No functions version specified so defaulting to 3. In the future, specifying a version will be required. To create a 3.x function you would pass in the flag `--functions-version 3`
 
--runtime-version is not supported for --runtime dotnet. Dotnet version is determined by --functions-version. Dotnet version will be 3.1 for this function app.
 
Your Linux function app 'pagombar-usw3-cli', that uses a consumption plan has been successfully created but is not active until content is published using Azure Portal or the Functions Core Tools.
 
Error while trying to create and configure an Application Insights for the Function App. Please use the Azure Portal to create and configure the Application Insights, if needed.

The function app gets created, but not Application Insights. Here is the output when the same command is ran with --debug flag:

cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/<subscriptionid-removed>/resourceGroups/nzthiwestus33/providers/Microsoft.Insights/components/nzthiwestus333-cli?api-version=2015-05-01'
cli.azure.cli.core.sdk.policies: Request method: 'PUT'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies:     'Content-Type': 'application/json'
cli.azure.cli.core.sdk.policies:     'Accept': 'application/json'
cli.azure.cli.core.sdk.policies:     'Content-Length': '81'
cli.azure.cli.core.sdk.policies:     'x-ms-client-request-id': 'e59320a7-794c-11ec-8831-c8348e1c4d50'
cli.azure.cli.core.sdk.policies:     'CommandName': 'functionapp create'
cli.azure.cli.core.sdk.policies:     'ParameterSetName': '--name --resource-group --storage-account --os-type --functions-version --runtime --consumption-plan-location --debug'
cli.azure.cli.core.sdk.policies:     'User-Agent': 'AZURECLI/2.32.0 (MSI) azsdk-python-azure-mgmt-applicationinsights/1.0.0
Python/3.8.9 (Windows-10-10.0.22000-SP0)'
cli.azure.cli.core.sdk.policies:     'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: {"location": "westus3", "kind": "web", "properties": {"Application_Type": "web"}}
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "PUT /subscriptions/<subscriptionid-removed>/resourceGroups/nzthiwestus33/providers/Microsoft.Insights/components/nzthiwestus333-cli?api-version=2015-05-01 HTTP/1.1" 400 261
cli.azure.cli.core.sdk.policies: Response status: 400
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies:     'Cache-Control': 'no-cache'
cli.azure.cli.core.sdk.policies:     'Pragma': 'no-cache'
cli.azure.cli.core.sdk.policies:     'Content-Length': '261'
cli.azure.cli.core.sdk.policies:     'Content-Type': 'application/json; charset=utf-8'
cli.azure.cli.core.sdk.policies:     'Expires': '-1'
cli.azure.cli.core.sdk.policies:     'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.sdk.policies:     'Request-Context': 'appId=cid-v1:920e14b1-13f3-461a-a4bb-b4fe6f1a4525'
cli.azure.cli.core.sdk.policies:     'Access-Control-Expose-Headers': 'Request-Context'
cli.azure.cli.core.sdk.policies:     'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies:     'Server': 'Microsoft-IIS/10.0'
cli.azure.cli.core.sdk.policies:     'x-ms-ratelimit-remaining-subscription-writes': '1199'
cli.azure.cli.core.sdk.policies:     'x-ms-request-id': '74b50abd-f7cd-471e-98bb-859322fbb86d'
cli.azure.cli.core.sdk.policies:     'x-ms-correlation-request-id': '74b50abd-f7cd-471e-98bb-859322fbb86d'
cli.azure.cli.core.sdk.policies:     'x-ms-routing-request-id': 'WESTUS2:20220119T172635Z:74b50abd-f7cd-471e-98bb-859322fbb8
6d'
cli.azure.cli.core.sdk.policies:     'Date': 'Wed, 19 Jan 2022 17:26:34 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {"code":"BadRequest","message":"Region doesn’t support Classic resource mode for Application Insights resources. Please use Workspace-based mode.","innererror":{"diagnosticcontext":"e59320a7-794c-11ec-8831-c8348e1c4
d50","time":"2022-01-19T17:26:34.8195205Z"}}
cli.azure.cli.command_modules.appservice.custom: Error while trying to create and configure an Application Insights for the
Function App. Please use the Azure Portal to create and configure the Application Insights, if needed.

To Reproduce Create a function app using azure cli in Jio India West or US West 3.

Expected behavior Function app and Application Insights gets created in all supported regions, including the ones above: Jio India West and US West 3.

Environment summary az-cli v2.30.0 and v2.32.0 on Windows.

Additional context When creating the same app from Azure Portal, the Portal uses apiVersion 2020-02-02-preview, which is newer than the version az CLI uses: 2015-05-01.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
nzthiagocommented, May 2, 2022

@panchagnula @pragnagopa the issue isn’t that App Insights is not available in the region; it is available, but App Insights in that region doesn’t support the older Classic resource mode for Application Insights resources, and only supports the newer Workspace-based Application Insights resources.

So this issue is more for the CLI to use the newer apiVersion for App Insights just like when creating the Function with App Insights via the Azure Portal. As per the note in the issue description at the time of creating this issue the Portal uses apiVersion 2020-02-02-preview for the App Insights portion, which is newer than the version the az CLI uses (2015-05-01) as per this part of the CLI debug logs:

cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: {"location": "westus3", "kind": "web", "properties": {"Application_Type": "web"}}
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "PUT /subscriptions/<subscriptionid-removed>/resourceGroups/nzthiwestus33/providers/Microsoft.Insights/components/nzthiwestus333-cli?api-version=2015-05-01 HTTP/1.1" 400 261
cli.azure.cli.core.sdk.policies: Response status: 400

Hope that clarifies it.

0reactions
nzthiagocommented, Jun 15, 2022

@mshelll It seems the docs still show the older API version. But I found the template reference and API Specs with examples, like the Create Component example.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure monitoring for Azure Functions - Microsoft Learn
The Application Insights resource has the same name as your function app, and it's created either in the same region or in the...
Read more >
Tuning App Insights for Azure Functions - Mike Stephenson
In my 2 function apps they both have host.json files with logging ... I can then run the az functionapp config appsettings set...
Read more >
Add Application Insights to an azure function with Azure CLI
After creating the function app by your command , just use the CLI command below. az functionapp config appsettings set --name <functionname> -- ......
Read more >
Dave Paquette
Creating a Function App. There are many options for creating a new function app. ... az functionapp deployment source config-zip -n davefuncapp123 --src...
Read more >
azurerm_function_app | Resources | hashicorp/azurerm
To connect an Azure Function App and a subnet within the same region ... Changing this forces a new resource to be created....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found