Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simple CLI commands #27964

Closed
alexkarcher-msft opened this issue Mar 25, 2019 — with docs.microsoft.com · 5 comments
Closed

Add simple CLI commands #27964

alexkarcher-msft opened this issue Mar 25, 2019 — with docs.microsoft.com · 5 comments

Comments

Copy link
Contributor

There are two very simple Azure CLI commands to create an app insights instance and get the instrumentation key. I'd love to see those documented here, or in a "CLI Quickstart" sister doc.

From this github thread: Azure/azure-cli#5543

az resource create \
                  --resource-group $RESOURCE_GROUP \
                  --resource-type "Microsoft.Insights/components" \
                  --name $NAMESPACE_PREFIX-appinsights \
                  --location $PRIMARY_LOCATION 

az resource show -g $RESOURCEGROUPNAME -n $APPLICATION_NAME --resource-type "Microsoft.Insights/components" --query properties.InstrumentationKey

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@MarileeTurscak-MSFT
Copy link
Contributor

@alexkarcher-msft
Thanks for your feedback! We will investigate and update as appropriate.

@kobulloc-MSFT
Copy link
Contributor

@alexkarcher-msft Thank you very much for the feedback! We're assigning this to the content author so they can update the documentation accordingly.

@mrbullwinkle
Copy link
Contributor

@alexkarcher-msft thanks for pointing this out, I will get it added this week.

@mrbullwinkle
Copy link
Contributor

Hey, sorry this stayed open so long. We have internally merged the following section to the create resource doc. The change will go-live between 3-4 PM (UTC-7). Thanks again for bringing this gap to our attention:

Creating a resource automatically

PowerShell

Create a new Application Insights resource

New-AzApplicationInsights [-ResourceGroupName] <String> [-Name] <String> [-Location] <String> [-Kind <String>]
 [-Tag <Hashtable>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]

Example

New-AzApplicationInsights -Kind java -ResourceGroupName testgroup -Name test1027 -location eastus

Results

Id                 : /subscriptions/{subid}/resourceGroups/testgroup/providers/microsoft.insights/components/test1027
ResourceGroupName  : testgroup
Name               : test1027
Kind               : web
Location           : eastus
Type               : microsoft.insights/components
AppId              : 8323fb13-32aa-46af-b467-8355cf4f8f98
ApplicationType    : web
Tags               : {}
CreationDate       : 10/27/2017 4:56:40 PM
FlowType           :
HockeyAppId        :
HockeyAppToken     :
InstrumentationKey : 00000000-aaaa-bbbb-cccc-dddddddddddd
ProvisioningState  : Succeeded
RequestSource      : AzurePowerShell
SamplingPercentage :
TenantId           : {subid}

For the full PowerShell documentation for this cmdlet, and to learn how to retrieve the instrumentation key consult the Azure PowerShell documentation.

Azure CLI (preview)

To access the preview Application Insights Azure CLI commands you first need to run:

 az extension add -n application-insights

If you don't run the az extension add command you will see an error message that states: az : ERROR: az monitor: 'app-insights' is not in the 'az monitor' command group. See 'az monitor --help'.

Now you can run the following to create your Application Insights resource:

az monitor app-insights component create --app
                                         --location
                                         --resource-group
                                         [--application-type]
                                         [--kind]
                                         [--tags]

Example

az monitor app-insights component create --app demoApp --location westus2 --kind web -g demoRg --application-type web

Results

az monitor app-insights component create --app demoApp --location eastus --kind web -g demoApp  --application-type web
{
  "appId": "87ba512c-e8c9-48d7-b6eb-118d4aee2697",
  "applicationId": "demoApp",
  "applicationType": "web",
  "creationDate": "2019-08-16T18:15:59.740014+00:00",
  "etag": "\"0300edb9-0000-0100-0000-5d56f2e00000\"",
  "flowType": "Bluefield",
  "hockeyAppId": null,
  "hockeyAppToken": null,
  "id": "/subscriptions/{subid}/resourceGroups/demoApp/providers/microsoft.insights/components/demoApp",
  "instrumentationKey": "00000000-aaaa-bbbb-cccc-dddddddddddd",
  "kind": "web",
  "location": "eastus",
  "name": "demoApp",
  "provisioningState": "Succeeded",
  "requestSource": "rest",
  "resourceGroup": "demoApp",
  "samplingPercentage": null,
  "tags": {},
  "tenantId": {tenantID},
  "type": "microsoft.insights/components"
}

For the full Azure CLI documentation for this command, and to learn how to retrieve the instrumentation key consult the Azure CLI documentation.

@PRMerger6 PRMerger6 added the Pri2 label Aug 16, 2019
@mrbullwinkle
Copy link
Contributor

#please-close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants