|
| 1 | +--- |
| 2 | +title: Create a new Azure Monitor Application Insights workspace-based resource | Microsoft Docs |
| 3 | +description: Learn about the steps required to enable the new Azure Monitor Application Insights workspace-based resources. |
| 4 | +author: mrbullwinkle |
| 5 | +ms.author: mbullwin |
| 6 | +ms.topic: conceptual |
| 7 | +ms.date: 12/02/2019 |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +# Workspace-based Application Insights resources (preview) |
| 12 | + |
| 13 | +Workspace-based resources support full integration between Application Insights and Log Analytics. You can now choose to send your Application Insights telemetry to a common Log Analytics workspace, which allows you full access to all the features of Log Analytics while keeping application, infrastructure, and platform logs in a single consolidated location. |
| 14 | + |
| 15 | +This also allows for common Role-Based Access Control (RBAC) across your resources, and eliminates the need for cross-app/workspace queries. |
| 16 | + |
| 17 | +> [!NOTE] |
| 18 | +> Data ingestion and retention for workspace-based Application Insights resources are billed through the Log Analytics workspace where the data is located. [Learn more]( https://docs.microsoft.com/azure/azure-monitor/app/pricing#workspace-based-application-insights) about billing for workspace-based Application Insights resources. |
| 19 | +
|
| 20 | +To test out the new experience, sign in to the [Azure portal](https://portal.azure.com), and create an Application Insights resource: |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +If you don't already have an existing Log Analytics Workspace, [consult the Log Analytics workspace creation documentation](https://docs.microsoft.com/azure/azure-monitor/learn/quick-create-workspace). |
| 25 | + |
| 26 | +For the public preview **workspace-based resources are currently limited to West US 2, East US, and South Central US.** |
| 27 | + |
| 28 | +Once your resource is created, you will see the corresponding workspace info in the **Overview** pane: |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | +Clicking the blue link text will take you to the associated Log Analytics workspace where you can take advantage of the new unified workspace query environment. |
| 33 | + |
| 34 | +> [!NOTE] |
| 35 | +> We still provide full backwards compatibility for your Application Insights classic resource queries, workbooks, and log-based alerts within the Application Insights experience. To query/view against the [new workspace-based table structure/schema](apm-tables.md) you must first navigate to your Log Analytics workspace. During the preview, selecting **Logs** from within the Application Insights panes will give you access to the classic Application Insights query experience. |
| 36 | +
|
| 37 | +## Copy the connection string |
| 38 | + |
| 39 | +The [connection string]() identifies the resource that you want to associate your telemetry data with. It also allows you to modify the endpoints your resource will use as a destination for your telemetry. You will need to copy the connection string and add it to your application's code or to an environment variable. |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | +## Monitoring configuration |
| 44 | + |
| 45 | +Once a workspace-based Application Insights resource has been created, configuring monitoring is relatively straightforward. |
| 46 | + |
| 47 | +### Code-based application monitoring |
| 48 | + |
| 49 | +For code-based application monitoring, you would just install the appropriate Application Insights SDK and point it to the instrumentation key or connection string to your newly created resource. |
| 50 | + |
| 51 | +For detailed documentation on setting up an Application Insights SDK for code-based monitoring consult the language/framework specific documentation: |
| 52 | + |
| 53 | +- [ASP.NET](https://docs.microsoft.com/azure/azure-monitor/app/asp-net) |
| 54 | +- [ASP.NET Core ](https://docs.microsoft.com/azure/azure-monitor/app/asp-net-core) |
| 55 | +- [Background tasks & modern console applications (.NET/.NET Core)](https://docs.microsoft.com/azure/azure-monitor/app/worker-service) |
| 56 | +- [Classic console applications (.NET)](https://docs.microsoft.com/azure/azure-monitor/app/console) |
| 57 | +- [Java ](https://docs.microsoft.com/azure/azure-monitor/app/java-get-started?tabs=maven) |
| 58 | +- [JavaScript](https://docs.microsoft.com/azure/azure-monitor/app/javascript) |
| 59 | +- [Node.js](https://docs.microsoft.com/azure/azure-monitor/app/nodejs) |
| 60 | +- [Python](https://docs.microsoft.com/azure/azure-monitor/app/opencensus-python) |
| 61 | + |
| 62 | +### Codeless monitoring and Visual Studio resource creation |
| 63 | + |
| 64 | +For codeless monitoring of services like Azure Functions and Azure App Services, you will also need to first create your workspace-based Application Insights resource and then point to that resource during the monitoring configuration phase. |
| 65 | + |
| 66 | +While these services offer the option to create a new Application Insights resource within their own resource creation process, resources created via these UI options are currently restricted to the classic Application Insights experience. |
| 67 | + |
| 68 | +The same applies to the Application Insights resource creation experience in Visual Studio for ASP.NET and ASP.NET Core. You must select an existing workspace-based resource from with the Visual Studio monitoring enablement UI. Selecting create new resource from within Visual Studio will limit you to creating a classic Application Insights resource. |
| 69 | + |
| 70 | +## Creating a resource automatically |
| 71 | + |
| 72 | +### Azure CLI |
| 73 | + |
| 74 | +To access the preview Application Insights Azure CLI commands, you first need to run: |
| 75 | + |
| 76 | +```azurecli |
| 77 | + az extension add -n application-insights |
| 78 | +``` |
| 79 | + |
| 80 | +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'.` |
| 81 | + |
| 82 | +Now you can run the following to create your Application Insights resource: |
| 83 | + |
| 84 | +```azurecli |
| 85 | +az monitor app-insights component create --app |
| 86 | + --location |
| 87 | + --resource-group |
| 88 | + [--application-type] |
| 89 | + [--ingestion-access {Disabled, Enabled}] |
| 90 | + [--kind] |
| 91 | + [--only-show-errors] |
| 92 | + [--query-access {Disabled, Enabled}] |
| 93 | + [--tags] |
| 94 | + [--workspace] |
| 95 | +``` |
| 96 | + |
| 97 | +#### Example |
| 98 | + |
| 99 | +```azurecli |
| 100 | +az monitor app-insights component create --app demoApp --location eastus --kind web -g my_resource_group --workspace "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test1234/providers/microsoft.operationalinsights/workspaces/test1234555" |
| 101 | +``` |
| 102 | + |
| 103 | +For the full Azure CLI documentation for this command, consult the [Azure CLI documentation](https://docs.microsoft.com/cli/azure/ext/application-insights/monitor/app-insights/component?view=azure-cli-latest#ext-application-insights-az-monitor-app-insights-component-create). |
| 104 | + |
| 105 | +### Azure PowerShell |
| 106 | + |
| 107 | +The `New-AzApplicationInsights` PowerShell command does not currently support creating a workspace-based Application Insights resource. To create a workspace-based resource with PowerShell, you can use the Azure Resource Manager templates below and deploy with PowerShell. |
| 108 | + |
| 109 | +### Azure Resource Manager templates |
| 110 | + |
| 111 | +#### Template file |
| 112 | + |
| 113 | +```json |
| 114 | +{ |
| 115 | + "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#", |
| 116 | + "contentVersion": "1.0.0.0", |
| 117 | + "parameters": { |
| 118 | + "name": { |
| 119 | + "type": "string" |
| 120 | + }, |
| 121 | + "type": { |
| 122 | + "type": "string" |
| 123 | + }, |
| 124 | + "regionId": { |
| 125 | + "type": "string" |
| 126 | + }, |
| 127 | + "tagsArray": { |
| 128 | + "type": "object" |
| 129 | + }, |
| 130 | + "requestSource": { |
| 131 | + "type": "string" |
| 132 | + }, |
| 133 | + "workspaceResourceId": { |
| 134 | + "type": "string" |
| 135 | + } |
| 136 | + }, |
| 137 | + "resources": [ |
| 138 | + { |
| 139 | + "name": "[parameters('name')]", |
| 140 | + "type": "microsoft.insights/components", |
| 141 | + "location": "[parameters('regionId')]", |
| 142 | + "tags": "[parameters('tagsArray')]", |
| 143 | + "apiVersion": "2020-02-02-preview", |
| 144 | + "properties": { |
| 145 | + "ApplicationId": "[parameters('name')]", |
| 146 | + "Application_Type": "[parameters('type')]", |
| 147 | + "Flow_Type": "Redfield", |
| 148 | + "Request_Source": "[parameters('requestSource')]", |
| 149 | + "WorkspaceResourceId": "[parameters('workspaceResourceId')]" |
| 150 | + } |
| 151 | + } |
| 152 | + ] |
| 153 | +} |
| 154 | +``` |
| 155 | + |
| 156 | +#### Parameters file |
| 157 | + |
| 158 | +```json |
| 159 | +{ |
| 160 | + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", |
| 161 | + "contentVersion": "1.0.0.0", |
| 162 | + "parameters": { |
| 163 | + "type": { |
| 164 | + "value": "web" |
| 165 | + }, |
| 166 | + "name": { |
| 167 | + "value": "customresourcename" |
| 168 | + }, |
| 169 | + "regionId": { |
| 170 | + "value": "eastus" |
| 171 | + }, |
| 172 | + "tagsArray": { |
| 173 | + "value": {} |
| 174 | + }, |
| 175 | + "requestSource": { |
| 176 | + "value": "Custom" |
| 177 | + }, |
| 178 | + "workspaceResourceId": { |
| 179 | + "value": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my_resource_group/providers/microsoft.operationalinsights/workspaces/myworkspacename" |
| 180 | + } |
| 181 | + } |
| 182 | +} |
| 183 | + |
| 184 | +``` |
| 185 | + |
| 186 | +## Modifying the associated workspace |
| 187 | + |
| 188 | +Once a workspace-based Application Insights resource has been created, you can modify the associated Log Analytics Workspace. |
| 189 | + |
| 190 | +From within the Application Insights resource pane, select **Properties** > **Change Workspace** > **Log Analytics Workspaces** |
| 191 | + |
| 192 | +## Next steps |
| 193 | + |
| 194 | +* [Explore metrics](../../azure-monitor/platform/metrics-charts.md) |
| 195 | +* [Write Analytics queries](../../azure-monitor/app/analytics.md) |
| 196 | + |
| 197 | +[api]: ../../azure-monitor/app/api-custom-events-metrics.md |
| 198 | +[diagnostic]: ../../azure-monitor/app/diagnostic-search.md |
| 199 | +[metrics]: ../../azure-monitor/platform/metrics-charts.md |
| 200 | +[start]: ../../azure-monitor/app/app-insights-overview.md |
0 commit comments