Skip to content

Commit 7219427

Browse files
author
Jill Grant
authored
Merge pull request #252096 from EdB-MSFT/add-tabs-lifecycle-migration
added cli and template tabs
2 parents 2c75343 + 6ffe557 commit 7219427

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed

articles/azure-monitor/essentials/migrate-to-azure-storage-lifecycle-policy.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ An existing diagnostic setting logging to a storage account.
3232

3333
## Migration Procedures
3434

35+
36+
## [Azure portal](#tab/portal)
3537
To migrate your diagnostics settings retention rules, follow the steps below:
3638

3739
1. Go to the Diagnostic Settings page for your logging resource and locate the diagnostic setting you wish to migrate
@@ -64,6 +66,124 @@ To set the rule for a specific webapp app, use *insights-activity-logs/ResourceI
6466
1. Select **Add** to save the rule.
6567
:::image type="content" source="./media/retention-migration/lifecycle-management-add-rule-filter-set.png" lightbox="./media/retention-migration/lifecycle-management-add-rule-filter-set.png" alt-text="A screenshot showing the filters tab for adding a lifecycle rule.":::
6668

69+
70+
## [CLI](#tab/cli)
71+
72+
Use the [az storage account management-policy create](https://docs.microsoft.com/cli/azure/storage/account/management-policy?view=azure-cli-latest#az-storage-account-management-policy-create) command to create a lifecycle management policy. You must still set the retention in your diagnostic settings to *0*. See the Azure portal section above for more information.
73+
74+
75+
76+
```azurecli
77+
78+
az storage account management-policy create --account-name <storage account name> --resource-group <resource group name> --policy @<policy definition file>
79+
```
80+
81+
The sample policy definition file below sets the retention for all blobs in the container *insights-activity-logs* for the given subscription ID. For more information, see [Lifecycle management policy definition](https://learn.microsoft.com/azure/storage/blobs/lifecycle-management-overview#lifecycle-management-policy-definition).
82+
83+
```json
84+
{
85+
"rules": [
86+
{
87+
"enabled": true,
88+
"name": "Susbcription level lifecycle rule",
89+
"type": "Lifecycle",
90+
"definition": {
91+
"actions": {
92+
"version": {
93+
"delete": {
94+
"daysAfterCreationGreaterThan": 90
95+
}
96+
},
97+
"baseBlob": {
98+
"tierToCool": {
99+
"daysAfterModificationGreaterThan": 30
100+
},
101+
"tierToArchive": {
102+
"daysAfterModificationGreaterThan": 90,
103+
"daysAfterLastTierChangeGreaterThan": 7
104+
},
105+
"delete": {
106+
"daysAfterModificationGreaterThan": 2555
107+
}
108+
}
109+
},
110+
"filters": {
111+
"blobTypes": [
112+
"blockBlob"
113+
],
114+
"prefixMatch": [
115+
"insights-activity-logs/ResourceId=/SUBSCRIPTIONS/ABCD1234-5849-ABCD-1234-9876543210AB"
116+
]
117+
}
118+
}
119+
}
120+
]
121+
}
122+
123+
``````
124+
125+
## [Templates](#tab/templates)
126+
127+
Apply the following template to create a lifecycle management policy. You must still set the retention in your diagnostic settings to *0*. See the Azure portal section above for more information.
128+
129+
```azurecli
130+
131+
az deployment group create --resource-group <resource group name> --template-file <template file>
132+
133+
``````
134+
135+
The following template sets the retention for storage account *azmonstorageaccount001* for all blobs in the container *insights-activity-logs* for all resources for the subscription ID *ABCD1234-5849-ABCD-1234-9876543210AB*.
136+
137+
```json
138+
{
139+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
140+
"contentVersion": "1.0.0.0",
141+
"resources": [
142+
{
143+
"type": "Microsoft.Storage/storageAccounts/managementPolicies",
144+
"apiVersion": "2021-02-01",
145+
"name": "azmonstorageaccount001/default",
146+
"properties": {
147+
"policy": {
148+
"rules": [
149+
{
150+
"enabled": true,
151+
"name": "Edtest",
152+
"type": "Lifecycle",
153+
"definition": {
154+
"filters": {
155+
"blobTypes": [
156+
"blockBlob"
157+
],
158+
"prefixMatch": [
159+
"insights-activity-logs/ResourceId=/SUBSCRIPTIONS/ABCD1234-5849-ABCD-1234-9876543210AB"
160+
]
161+
},
162+
"actions": {
163+
"baseBlob": {
164+
"tierToCool": {
165+
"daysAfterModificationGreaterThan": 30
166+
},
167+
"tierToArchive": {
168+
"daysAfterModificationGreaterThan": 90
169+
},
170+
"delete": {
171+
"daysAfterModificationGreaterThan": 1000
172+
}
173+
}
174+
}
175+
}
176+
}
177+
]
178+
}
179+
}
180+
}
181+
]
182+
}
183+
``````
184+
185+
---
186+
67187
## Next steps
68188

69189
[Configure a lifecycle management policy](../../storage/blobs/lifecycle-management-policy-configure.md?tabs=azure-portal).

0 commit comments

Comments
 (0)