You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-monitor/app/powershell.md
+32-16Lines changed: 32 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: Automate Azure Application Insights with PowerShell | Microsoft Docs
3
3
description: Automate creating and managing resources, alerts, and availability tests in PowerShell using an Azure Resource Manager template.
4
4
ms.topic: conceptual
5
-
ms.date: 10/17/2019
5
+
ms.date: 05/02/2020
6
6
7
7
---
8
8
@@ -17,10 +17,10 @@ The key to creating these resources is JSON templates for [Azure Resource Manage
17
17
## One-time setup
18
18
If you haven't used PowerShell with your Azure subscription before:
19
19
20
-
Install the Azure Powershell module on the machine where you want to run the scripts:
20
+
Install the Azure PowerShell module on the machine where you want to run the scripts:
21
21
22
22
1. Install [Microsoft Web Platform Installer (v5 or higher)](https://www.microsoft.com/web/downloads/platform.aspx).
23
-
2. Use it to install Microsoft Azure Powershell.
23
+
2. Use it to install Microsoft Azure PowerShell.
24
24
25
25
In addition to using Resource Manager templates, there is a rich set of [Application Insights PowerShell cmdlets](https://docs.microsoft.com/powershell/module/az.applicationinsights), which make it easy to configure Application Insights resources programatically. The capabilities enabled by the cmdlets include:
26
26
@@ -83,20 +83,20 @@ Create a new .json file - let's call it `template1.json` in this example. Copy t
83
83
"defaultValue": 90,
84
84
"allowedValues": [
85
85
30,
86
-
60,
87
-
90,
88
-
120,
89
-
180,
90
-
270,
91
-
365,
92
-
550,
93
-
730
86
+
60,
87
+
90,
88
+
120,
89
+
180,
90
+
270,
91
+
365,
92
+
550,
93
+
730
94
94
],
95
95
"metadata": {
96
96
"description": "Data retention in days"
97
97
}
98
98
},
99
-
"ImmediatePurgeDataOn30Days": {
99
+
"ImmediatePurgeDataOn30Days": {
100
100
"type": "bool",
101
101
"defaultValue": false,
102
102
"metadata": {
@@ -225,7 +225,21 @@ Additional properties are available via the cmdlets:
225
225
226
226
Refer to the [detailed documentation](https://docs.microsoft.com/powershell/module/az.applicationinsights) for the parameters for these cmdlets.
227
227
228
-
## Set the data retention
228
+
## Set the data retention
229
+
230
+
Below are three methods to programmatically set the data retention on an Application Insights resource.
231
+
232
+
### Setting data retention using a PowerShell commands
233
+
234
+
Here's a simple set of PowerShell commands to set the data retention for your Application Insights resource:
To get the current data retention for your Application Insights resource, you can use the OSS tool [ARMClient](https://github.com/projectkudu/ARMClient). (Learn more about ARMClient from articles by [David Ebbo](http://blog.davidebbo.com/2015/01/azure-resource-manager-client.html) and [Daniel Bowbyes](https://blog.bowbyes.co.nz/2016/11/02/using-armclient-to-directly-access-azure-arm-rest-apis-and-list-arm-policy-details/).) Here's an example using `ARMClient`, to get the current retention:
0 commit comments