Azure-cli: "az functionapp create" should create app insights by default

Created on 20 Nov 2018  Â·  12Comments  Â·  Source: Azure/azure-cli

Is your feature request related to a problem? Please describe.
Currently all function apps created by any of the tools - except Az CLI - has app insights created and configured

Describe the solution you'd like
"az functionapp create" should create app insights by default

Describe alternatives you've considered
Create the app insights and configure the instrumentation key after the fact

Additional context
None

Functions Functions-cli

Most helpful comment

@ahmedelnably, This is fixed in https://github.com/Azure/azure-cli/pull/8081. Please close this issue :)

All 12 comments

@ahmedelnably Looking for the possible ways to support this, I didn't see direct support for creating an app insights from the azure-cli (az). Please correct me if I am wrong.

Would you know what are the ways to create an app insights project right now (other than going through the portal)?

@ankitkumarr you are correct, there is no app insights commands in the CLI, but app insights mgmt library exists in the Python SDK, it should have create operation that we can use to create the app insights instance that we can use to configure the functionapp.

If the create operation is not available we can explore using the ARM rest apis directly which is definitely not recommended, or check with app insights team to include the create in their swagger (may need more time to execute on)

@ahmedelnably, thanks for the fast response! I will explore azure-mgmt-applicationinsights and see if we can use that. We would have to add azure-mgmt-applicationinsights dependency in this project.

@ahmedelnably, you are right! azure-mgmt-applicationinsights should work fine. Looks like it has a create_or_update operation. I just have a few clarification questions regarding the workflow-

  • The default should be to create an app insights with the same name in the same resource group as the function, right? We should probably also have parameters to override this?

  • What about the location of appinsights? Should we default that to their plan location and have an option to override? EDIT: I realized we can't default this because appinsights are not available in all the regions functions are available in.

  • Additionally, we probably also want to have an opt-out for not creating an application insights?

It would be best to match the same experience in the UX.

  • The UX default to same rg as the functionapp, but allow to override
  • The UX asks the user for the app insights location
  • The UX allows using an existing app insights resource (under the same subID)
  • The UX have app insights disabled by default
    Let's match the same behavior, where if the user don't provide the app insights parameters we leave it disabled, and add app insights only if the user provide the new optional app insights parameters

Thoughts?

Thoughts

@ahmedelnably, that does sound good to me.

@ahmedelnably, Right now, the portal tries to create the App Insights with the same name as the name of the function. If the name is not available for App Insights, it add a timestamp after. So if the function is called "function" and an app insights already exists, it prompts to create "function201812171947" (201812171947 being the timestamp I guess), also allowing the user to override if they wish. Would you say we should add the same behavior?

That's actually tricky because the portal can show the user the new name before actually creating.
My guts would say let's fail the whole command with an error saying that the provided name for app insights is already taken - exactly if they provided a Function App name that is already taken. And then the user can choose another name.

Thoughts?

Updating this issue on our offline discussion:
We will not add support to create App Insights from az functionapp create command. But instead, we will allow users to provide an existing App Insights or an Instrumentation key. We did so to avoid ownership and maintenance issues while also keeping things consistent with how we deal with storage.

@ahmedelnably, This is fixed in https://github.com/Azure/azure-cli/pull/8081. Please close this issue :)

Reopening the issue as we have new requirements:
Proposed design:

  1. The user need to do a single action to create a Function app that is configured with App Insights
  2. Every Function App created through CLI should have App Insights enabled by default
    o The user can specify:
    i. Instrumentation Key
    ii. App Insights resource ID
    iii. Opt-Out from App Insights creation/configuration
  3. Add a command to configure an existing Function App with App Insights
    o The user can specify:
    i. Instrumentation Key
    ii. App Insights resource ID
    iii. Remove App Insights support (no deletion required)

Proposed New design:
Opting out:
az functionapp create ….. --app-insights-opt-out
If the flag is passed, we will create a Function app without configuring app insights
On by default:
az functionapp create ….
Nothing app insights flags passed, we create a new app insights instance in the same resource group, with a auto generated name ex. -AI-
Configure an existing app:
az functionapp config app-insights --app-insights
Work like in create
az functionapp config app-insights --app-insights-key
Work like in create
az functionapp config app-insights --app-insights-disable
Remove the instrumentation key app setting (disconnecting from App Insights)

AI Region choice:
 If the user have access to the functionapp’s region for App insights (exact match) --> choose this region
 If the user doesn’t have access --> check the region mapping
• If there is a recommended region with user having access to --> choose this region
• If no recommended region with user having access to --> do not create the AI instance

@ahmedelnably can you add Sprint 64 milestone to this please? I will get this in as part of this sprint.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dhermans picture dhermans  Â·  3Comments

troydai picture troydai  Â·  3Comments

ambakshi picture ambakshi  Â·  3Comments

oakeyc picture oakeyc  Â·  3Comments

Kannaj picture Kannaj  Â·  3Comments