Skip to content

Commit 3823edf

Browse files
authoredJul 16, 2021
[Storage] az storage account blob-service-properties: Support last access tracking policy (Azure#18731)
1 parent 82a21bf commit 3823edf

File tree

6 files changed

+556
-31
lines changed

6 files changed

+556
-31
lines changed
 

‎src/azure-cli/azure/cli/command_modules/storage/_params.py

+3
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,9 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
553553
type=get_api_version_type(), min_api='2018-07-01',
554554
help="Indicate the default version to use for requests to the Blob service if an incoming request's "
555555
"version is not specified.")
556+
c.argument('enable_last_access_tracking', arg_type=get_three_state_flag(), min_api='2019-06-01',
557+
options_list=['--enable-last-access-tracking', '-t'],
558+
help='When set to true last access time based tracking policy is enabled.')
556559

557560
with self.argument_context('storage account file-service-properties show',
558561
resource_type=ResourceType.MGMT_STORAGE) as c:

‎src/azure-cli/azure/cli/command_modules/storage/operations/account.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,8 @@ def update_blob_service_properties(cmd, instance, enable_change_feed=None, chang
616616
enable_delete_retention=None, delete_retention_days=None,
617617
enable_restore_policy=None, restore_days=None,
618618
enable_versioning=None, enable_container_delete_retention=None,
619-
container_delete_retention_days=None, default_service_version=None):
619+
container_delete_retention_days=None, default_service_version=None,
620+
enable_last_access_tracking=None):
620621
if enable_change_feed is not None:
621622
if enable_change_feed is False:
622623
change_feed_retention_days = None
@@ -647,6 +648,11 @@ def update_blob_service_properties(cmd, instance, enable_change_feed=None, chang
647648
if default_service_version is not None:
648649
instance.default_service_version = default_service_version
649650

651+
# Update last access time tracking policy
652+
if enable_last_access_tracking is not None:
653+
LastAccessTimeTrackingPolicy = cmd.get_models('LastAccessTimeTrackingPolicy')
654+
instance.last_access_time_tracking_policy = LastAccessTimeTrackingPolicy(enable=enable_last_access_tracking)
655+
650656
return instance
651657

652658

‎src/azure-cli/azure/cli/command_modules/storage/tests/latest/mgmt_policy.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
]
1414
},
1515
"actions": {
16-
"baseBlob": {
16+
"baseBlob": {
1717
"tierToCool": {
18-
"daysAfterModificationGreaterThan": 30
18+
"daysAfterLastAccessTimeGreaterThan": 30
1919
},
2020
"tierToArchive": {
2121
"daysAfterModificationGreaterThan": 90

‎src/azure-cli/azure/cli/command_modules/storage/tests/latest/recordings/test_management_policy.yaml

+126-27
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,106 @@
11
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- application/json
7+
Accept-Encoding:
8+
- gzip, deflate
9+
CommandName:
10+
- storage account blob-service-properties update
11+
Connection:
12+
- keep-alive
13+
ParameterSetName:
14+
- --enable-last-access-tracking -n -g
15+
User-Agent:
16+
- AZURECLI/2.26.0 azsdk-python-azure-mgmt-storage/18.0.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
17+
method: GET
18+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default?api-version=2021-04-01
19+
response:
20+
body:
21+
string: '{"sku":{"name":"Standard_LRS","tier":"Standard"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default","name":"default","type":"Microsoft.Storage/storageAccounts/blobServices","properties":{"cors":{"corsRules":[]},"deleteRetentionPolicy":{"enabled":false}}}'
22+
headers:
23+
cache-control:
24+
- no-cache
25+
content-length:
26+
- '443'
27+
content-type:
28+
- application/json
29+
date:
30+
- Mon, 05 Jul 2021 08:30:18 GMT
31+
expires:
32+
- '-1'
33+
pragma:
34+
- no-cache
35+
server:
36+
- Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0
37+
strict-transport-security:
38+
- max-age=31536000; includeSubDomains
39+
transfer-encoding:
40+
- chunked
41+
vary:
42+
- Accept-Encoding
43+
x-content-type-options:
44+
- nosniff
45+
status:
46+
code: 200
47+
message: OK
48+
- request:
49+
body: '{"properties": {"cors": {"corsRules": []}, "deleteRetentionPolicy": {"enabled":
50+
false}, "lastAccessTimeTrackingPolicy": {"enable": true}}}'
51+
headers:
52+
Accept:
53+
- application/json
54+
Accept-Encoding:
55+
- gzip, deflate
56+
CommandName:
57+
- storage account blob-service-properties update
58+
Connection:
59+
- keep-alive
60+
Content-Length:
61+
- '138'
62+
Content-Type:
63+
- application/json
64+
ParameterSetName:
65+
- --enable-last-access-tracking -n -g
66+
User-Agent:
67+
- AZURECLI/2.26.0 azsdk-python-azure-mgmt-storage/18.0.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
68+
method: PUT
69+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default?api-version=2021-04-01
70+
response:
71+
body:
72+
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default","name":"default","type":"Microsoft.Storage/storageAccounts/blobServices","properties":{"lastAccessTimeTrackingPolicy":{"enable":true,"name":"AccessTimeTracking","trackingGranularityInDays":1,"blobType":["blockBlob"]},"cors":{"corsRules":[]},"deleteRetentionPolicy":{"enabled":false}}}'
73+
headers:
74+
cache-control:
75+
- no-cache
76+
content-length:
77+
- '525'
78+
content-type:
79+
- application/json
80+
date:
81+
- Mon, 05 Jul 2021 08:30:21 GMT
82+
expires:
83+
- '-1'
84+
pragma:
85+
- no-cache
86+
server:
87+
- Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0
88+
strict-transport-security:
89+
- max-age=31536000; includeSubDomains
90+
transfer-encoding:
91+
- chunked
92+
vary:
93+
- Accept-Encoding
94+
x-content-type-options:
95+
- nosniff
96+
x-ms-ratelimit-remaining-subscription-writes:
97+
- '1199'
98+
status:
99+
code: 200
100+
message: OK
2101
- request:
3102
body: '{"properties": {"policy": {"rules": [{"name": "olcmtest", "type": "Lifecycle",
4-
"definition": {"actions": {"baseBlob": {"tierToCool": {"daysAfterModificationGreaterThan":
103+
"definition": {"actions": {"baseBlob": {"tierToCool": {"daysAfterLastAccessTimeGreaterThan":
5104
30.0}, "tierToArchive": {"daysAfterModificationGreaterThan": 90.0}, "delete":
6105
{"daysAfterModificationGreaterThan": 1000.0}}, "snapshot": {"tierToCool": {"daysAfterCreationGreaterThan":
7106
30.0}, "tierToArchive": {"daysAfterCreationGreaterThan": 90.0}, "delete": {"daysAfterCreationGreaterThan":
@@ -18,27 +117,27 @@ interactions:
18117
Connection:
19118
- keep-alive
20119
Content-Length:
21-
- '733'
120+
- '735'
22121
Content-Type:
23122
- application/json
24123
ParameterSetName:
25124
- --account-name -g --policy
26125
User-Agent:
27-
- AZURECLI/2.23.0 azsdk-python-azure-mgmt-storage/17.1.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
126+
- AZURECLI/2.26.0 azsdk-python-azure-mgmt-storage/18.0.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
28127
method: PUT
29128
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/managementPolicies/default?api-version=2021-04-01
30129
response:
31130
body:
32-
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/managementPolicies/default","name":"DefaultManagementPolicy","type":"Microsoft.Storage/storageAccounts/managementPolicies","properties":{"policy":{"rules":[{"enabled":true,"name":"olcmtest","type":"Lifecycle","definition":{"actions":{"version":{"tierToCool":{"daysAfterCreationGreaterThan":30.0},"tierToArchive":{"daysAfterCreationGreaterThan":90.0},"delete":{"daysAfterCreationGreaterThan":1000.0}},"baseBlob":{"tierToCool":{"daysAfterModificationGreaterThan":30.0},"tierToArchive":{"daysAfterModificationGreaterThan":90.0},"delete":{"daysAfterModificationGreaterThan":1000.0}},"snapshot":{"tierToCool":{"daysAfterCreationGreaterThan":30.0},"tierToArchive":{"daysAfterCreationGreaterThan":90.0},"delete":{"daysAfterCreationGreaterThan":1000.0}}},"filters":{"blobTypes":["blockBlob"],"prefixMatch":["olcmtestcontainer1"]}}}]},"lastModifiedTime":"2021-05-11T02:17:55.1909549Z"}}'
131+
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/managementPolicies/default","name":"DefaultManagementPolicy","type":"Microsoft.Storage/storageAccounts/managementPolicies","properties":{"policy":{"rules":[{"enabled":true,"name":"olcmtest","type":"Lifecycle","definition":{"actions":{"version":{"tierToCool":{"daysAfterCreationGreaterThan":30.0},"tierToArchive":{"daysAfterCreationGreaterThan":90.0},"delete":{"daysAfterCreationGreaterThan":1000.0}},"baseBlob":{"tierToCool":{"daysAfterLastAccessTimeGreaterThan":30.0},"tierToArchive":{"daysAfterModificationGreaterThan":90.0},"delete":{"daysAfterModificationGreaterThan":1000.0}},"snapshot":{"tierToCool":{"daysAfterCreationGreaterThan":30.0},"tierToArchive":{"daysAfterCreationGreaterThan":90.0},"delete":{"daysAfterCreationGreaterThan":1000.0}}},"filters":{"blobTypes":["blockBlob"],"prefixMatch":["olcmtestcontainer1"]}}}]},"lastModifiedTime":"2021-07-05T08:30:23.4069774Z"}}'
33132
headers:
34133
cache-control:
35134
- no-cache
36135
content-length:
37-
- '1096'
136+
- '1098'
38137
content-type:
39138
- application/json
40139
date:
41-
- Tue, 11 May 2021 02:17:54 GMT
140+
- Mon, 05 Jul 2021 08:30:23 GMT
42141
expires:
43142
- '-1'
44143
pragma:
@@ -54,7 +153,7 @@ interactions:
54153
x-content-type-options:
55154
- nosniff
56155
x-ms-ratelimit-remaining-subscription-writes:
57-
- '1196'
156+
- '1199'
58157
status:
59158
code: 200
60159
message: OK
@@ -72,21 +171,21 @@ interactions:
72171
ParameterSetName:
73172
- --account-name -g --set
74173
User-Agent:
75-
- AZURECLI/2.23.0 azsdk-python-azure-mgmt-storage/17.1.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
174+
- AZURECLI/2.26.0 azsdk-python-azure-mgmt-storage/18.0.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
76175
method: GET
77176
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/managementPolicies/default?api-version=2021-04-01
78177
response:
79178
body:
80-
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/managementPolicies/default","name":"DefaultManagementPolicy","type":"Microsoft.Storage/storageAccounts/managementPolicies","properties":{"policy":{"rules":[{"enabled":true,"name":"olcmtest","type":"Lifecycle","definition":{"actions":{"version":{"tierToCool":{"daysAfterCreationGreaterThan":30.0},"tierToArchive":{"daysAfterCreationGreaterThan":90.0},"delete":{"daysAfterCreationGreaterThan":1000.0}},"baseBlob":{"tierToCool":{"daysAfterModificationGreaterThan":30.0},"tierToArchive":{"daysAfterModificationGreaterThan":90.0},"delete":{"daysAfterModificationGreaterThan":1000.0}},"snapshot":{"tierToCool":{"daysAfterCreationGreaterThan":30.0},"tierToArchive":{"daysAfterCreationGreaterThan":90.0},"delete":{"daysAfterCreationGreaterThan":1000.0}}},"filters":{"blobTypes":["blockBlob"],"prefixMatch":["olcmtestcontainer1"]}}}]},"lastModifiedTime":"2021-05-11T02:17:55.1909549Z"}}'
179+
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/managementPolicies/default","name":"DefaultManagementPolicy","type":"Microsoft.Storage/storageAccounts/managementPolicies","properties":{"policy":{"rules":[{"enabled":true,"name":"olcmtest","type":"Lifecycle","definition":{"actions":{"version":{"tierToCool":{"daysAfterCreationGreaterThan":30.0},"tierToArchive":{"daysAfterCreationGreaterThan":90.0},"delete":{"daysAfterCreationGreaterThan":1000.0}},"baseBlob":{"tierToCool":{"daysAfterLastAccessTimeGreaterThan":30.0},"tierToArchive":{"daysAfterModificationGreaterThan":90.0},"delete":{"daysAfterModificationGreaterThan":1000.0}},"snapshot":{"tierToCool":{"daysAfterCreationGreaterThan":30.0},"tierToArchive":{"daysAfterCreationGreaterThan":90.0},"delete":{"daysAfterCreationGreaterThan":1000.0}}},"filters":{"blobTypes":["blockBlob"],"prefixMatch":["olcmtestcontainer1"]}}}]},"lastModifiedTime":"2021-07-05T08:30:23.4069774Z"}}'
81180
headers:
82181
cache-control:
83182
- no-cache
84183
content-length:
85-
- '1096'
184+
- '1098'
86185
content-type:
87186
- application/json
88187
date:
89-
- Tue, 11 May 2021 02:17:55 GMT
188+
- Mon, 05 Jul 2021 08:30:23 GMT
90189
expires:
91190
- '-1'
92191
pragma:
@@ -106,7 +205,7 @@ interactions:
106205
message: OK
107206
- request:
108207
body: '{"properties": {"policy": {"rules": [{"enabled": true, "name": "newname",
109-
"type": "Lifecycle", "definition": {"actions": {"baseBlob": {"tierToCool": {"daysAfterModificationGreaterThan":
208+
"type": "Lifecycle", "definition": {"actions": {"baseBlob": {"tierToCool": {"daysAfterLastAccessTimeGreaterThan":
110209
30.0}, "tierToArchive": {"daysAfterModificationGreaterThan": 90.0}, "delete":
111210
{"daysAfterModificationGreaterThan": 1000.0}}, "snapshot": {"tierToCool": {"daysAfterCreationGreaterThan":
112211
30.0}, "tierToArchive": {"daysAfterCreationGreaterThan": 90.0}, "delete": {"daysAfterCreationGreaterThan":
@@ -123,27 +222,27 @@ interactions:
123222
Connection:
124223
- keep-alive
125224
Content-Length:
126-
- '749'
225+
- '751'
127226
Content-Type:
128227
- application/json
129228
ParameterSetName:
130229
- --account-name -g --set
131230
User-Agent:
132-
- AZURECLI/2.23.0 azsdk-python-azure-mgmt-storage/17.1.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
231+
- AZURECLI/2.26.0 azsdk-python-azure-mgmt-storage/18.0.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
133232
method: PUT
134233
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/managementPolicies/default?api-version=2021-04-01
135234
response:
136235
body:
137-
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/managementPolicies/default","name":"DefaultManagementPolicy","type":"Microsoft.Storage/storageAccounts/managementPolicies","properties":{"policy":{"rules":[{"enabled":true,"name":"newname","type":"Lifecycle","definition":{"actions":{"version":{"tierToCool":{"daysAfterCreationGreaterThan":30.0},"tierToArchive":{"daysAfterCreationGreaterThan":90.0},"delete":{"daysAfterCreationGreaterThan":1000.0}},"baseBlob":{"tierToCool":{"daysAfterModificationGreaterThan":30.0},"tierToArchive":{"daysAfterModificationGreaterThan":90.0},"delete":{"daysAfterModificationGreaterThan":1000.0}},"snapshot":{"tierToCool":{"daysAfterCreationGreaterThan":30.0},"tierToArchive":{"daysAfterCreationGreaterThan":90.0},"delete":{"daysAfterCreationGreaterThan":1000.0}}},"filters":{"blobTypes":["blockBlob"],"prefixMatch":["olcmtestcontainer1"]}}}]},"lastModifiedTime":"2021-05-11T02:17:56.6284542Z"}}'
236+
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/managementPolicies/default","name":"DefaultManagementPolicy","type":"Microsoft.Storage/storageAccounts/managementPolicies","properties":{"policy":{"rules":[{"enabled":true,"name":"newname","type":"Lifecycle","definition":{"actions":{"version":{"tierToCool":{"daysAfterCreationGreaterThan":30.0},"tierToArchive":{"daysAfterCreationGreaterThan":90.0},"delete":{"daysAfterCreationGreaterThan":1000.0}},"baseBlob":{"tierToCool":{"daysAfterLastAccessTimeGreaterThan":30.0},"tierToArchive":{"daysAfterModificationGreaterThan":90.0},"delete":{"daysAfterModificationGreaterThan":1000.0}},"snapshot":{"tierToCool":{"daysAfterCreationGreaterThan":30.0},"tierToArchive":{"daysAfterCreationGreaterThan":90.0},"delete":{"daysAfterCreationGreaterThan":1000.0}}},"filters":{"blobTypes":["blockBlob"],"prefixMatch":["olcmtestcontainer1"]}}}]},"lastModifiedTime":"2021-07-05T08:30:25.2194820Z"}}'
138237
headers:
139238
cache-control:
140239
- no-cache
141240
content-length:
142-
- '1095'
241+
- '1097'
143242
content-type:
144243
- application/json
145244
date:
146-
- Tue, 11 May 2021 02:17:55 GMT
245+
- Mon, 05 Jul 2021 08:30:24 GMT
147246
expires:
148247
- '-1'
149248
pragma:
@@ -159,7 +258,7 @@ interactions:
159258
x-content-type-options:
160259
- nosniff
161260
x-ms-ratelimit-remaining-subscription-writes:
162-
- '1199'
261+
- '1197'
163262
status:
164263
code: 200
165264
message: OK
@@ -177,21 +276,21 @@ interactions:
177276
ParameterSetName:
178277
- --account-name -g
179278
User-Agent:
180-
- AZURECLI/2.23.0 azsdk-python-azure-mgmt-storage/17.1.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
279+
- AZURECLI/2.26.0 azsdk-python-azure-mgmt-storage/18.0.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
181280
method: GET
182281
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/managementPolicies/default?api-version=2021-04-01
183282
response:
184283
body:
185-
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/managementPolicies/default","name":"DefaultManagementPolicy","type":"Microsoft.Storage/storageAccounts/managementPolicies","properties":{"policy":{"rules":[{"enabled":true,"name":"newname","type":"Lifecycle","definition":{"actions":{"version":{"tierToCool":{"daysAfterCreationGreaterThan":30.0},"tierToArchive":{"daysAfterCreationGreaterThan":90.0},"delete":{"daysAfterCreationGreaterThan":1000.0}},"baseBlob":{"tierToCool":{"daysAfterModificationGreaterThan":30.0},"tierToArchive":{"daysAfterModificationGreaterThan":90.0},"delete":{"daysAfterModificationGreaterThan":1000.0}},"snapshot":{"tierToCool":{"daysAfterCreationGreaterThan":30.0},"tierToArchive":{"daysAfterCreationGreaterThan":90.0},"delete":{"daysAfterCreationGreaterThan":1000.0}}},"filters":{"blobTypes":["blockBlob"],"prefixMatch":["olcmtestcontainer1"]}}}]},"lastModifiedTime":"2021-05-11T02:17:56.6284542Z"}}'
284+
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/managementPolicies/default","name":"DefaultManagementPolicy","type":"Microsoft.Storage/storageAccounts/managementPolicies","properties":{"policy":{"rules":[{"enabled":true,"name":"newname","type":"Lifecycle","definition":{"actions":{"version":{"tierToCool":{"daysAfterCreationGreaterThan":30.0},"tierToArchive":{"daysAfterCreationGreaterThan":90.0},"delete":{"daysAfterCreationGreaterThan":1000.0}},"baseBlob":{"tierToCool":{"daysAfterLastAccessTimeGreaterThan":30.0},"tierToArchive":{"daysAfterModificationGreaterThan":90.0},"delete":{"daysAfterModificationGreaterThan":1000.0}},"snapshot":{"tierToCool":{"daysAfterCreationGreaterThan":30.0},"tierToArchive":{"daysAfterCreationGreaterThan":90.0},"delete":{"daysAfterCreationGreaterThan":1000.0}}},"filters":{"blobTypes":["blockBlob"],"prefixMatch":["olcmtestcontainer1"]}}}]},"lastModifiedTime":"2021-07-05T08:30:25.2194820Z"}}'
186285
headers:
187286
cache-control:
188287
- no-cache
189288
content-length:
190-
- '1095'
289+
- '1097'
191290
content-type:
192291
- application/json
193292
date:
194-
- Tue, 11 May 2021 02:17:57 GMT
293+
- Mon, 05 Jul 2021 08:30:25 GMT
195294
expires:
196295
- '-1'
197296
pragma:
@@ -225,7 +324,7 @@ interactions:
225324
ParameterSetName:
226325
- --account-name -g
227326
User-Agent:
228-
- AZURECLI/2.23.0 azsdk-python-azure-mgmt-storage/17.1.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
327+
- AZURECLI/2.26.0 azsdk-python-azure-mgmt-storage/18.0.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
229328
method: DELETE
230329
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/managementPolicies/default?api-version=2021-04-01
231330
response:
@@ -239,7 +338,7 @@ interactions:
239338
content-type:
240339
- text/plain; charset=utf-8
241340
date:
242-
- Tue, 11 May 2021 02:17:58 GMT
341+
- Mon, 05 Jul 2021 08:30:27 GMT
243342
expires:
244343
- '-1'
245344
pragma:
@@ -251,7 +350,7 @@ interactions:
251350
x-content-type-options:
252351
- nosniff
253352
x-ms-ratelimit-remaining-subscription-deletes:
254-
- '14999'
353+
- '14998'
255354
status:
256355
code: 200
257356
message: OK
@@ -269,7 +368,7 @@ interactions:
269368
ParameterSetName:
270369
- --account-name -g
271370
User-Agent:
272-
- AZURECLI/2.23.0 azsdk-python-azure-mgmt-storage/17.1.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
371+
- AZURECLI/2.26.0 azsdk-python-azure-mgmt-storage/18.0.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
273372
method: GET
274373
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/managementPolicies/default?api-version=2021-04-01
275374
response:
@@ -284,7 +383,7 @@ interactions:
284383
content-type:
285384
- application/json
286385
date:
287-
- Tue, 11 May 2021 02:17:59 GMT
386+
- Mon, 05 Jul 2021 08:30:29 GMT
288387
expires:
289388
- '-1'
290389
pragma:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,391 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- application/json
7+
Accept-Encoding:
8+
- gzip, deflate
9+
CommandName:
10+
- storage account blob-service-properties update
11+
Connection:
12+
- keep-alive
13+
ParameterSetName:
14+
- --enable-last-access-tracking -n -g
15+
User-Agent:
16+
- AZURECLI/2.26.0 azsdk-python-azure-mgmt-storage/18.0.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
17+
method: GET
18+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_sa_versioning000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default?api-version=2021-04-01
19+
response:
20+
body:
21+
string: '{"sku":{"name":"Standard_LRS","tier":"Standard"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_sa_versioning000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default","name":"default","type":"Microsoft.Storage/storageAccounts/blobServices","properties":{"cors":{"corsRules":[]},"deleteRetentionPolicy":{"enabled":false}}}'
22+
headers:
23+
cache-control:
24+
- no-cache
25+
content-length:
26+
- '443'
27+
content-type:
28+
- application/json
29+
date:
30+
- Mon, 05 Jul 2021 08:26:55 GMT
31+
expires:
32+
- '-1'
33+
pragma:
34+
- no-cache
35+
server:
36+
- Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0
37+
strict-transport-security:
38+
- max-age=31536000; includeSubDomains
39+
transfer-encoding:
40+
- chunked
41+
vary:
42+
- Accept-Encoding
43+
x-content-type-options:
44+
- nosniff
45+
status:
46+
code: 200
47+
message: OK
48+
- request:
49+
body: '{"properties": {"cors": {"corsRules": []}, "deleteRetentionPolicy": {"enabled":
50+
false}, "lastAccessTimeTrackingPolicy": {"enable": true}}}'
51+
headers:
52+
Accept:
53+
- application/json
54+
Accept-Encoding:
55+
- gzip, deflate
56+
CommandName:
57+
- storage account blob-service-properties update
58+
Connection:
59+
- keep-alive
60+
Content-Length:
61+
- '138'
62+
Content-Type:
63+
- application/json
64+
ParameterSetName:
65+
- --enable-last-access-tracking -n -g
66+
User-Agent:
67+
- AZURECLI/2.26.0 azsdk-python-azure-mgmt-storage/18.0.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
68+
method: PUT
69+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_sa_versioning000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default?api-version=2021-04-01
70+
response:
71+
body:
72+
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_sa_versioning000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default","name":"default","type":"Microsoft.Storage/storageAccounts/blobServices","properties":{"cors":{"corsRules":[]},"deleteRetentionPolicy":{"enabled":false},"lastAccessTimeTrackingPolicy":{"enable":true,"name":"AccessTimeTracking","trackingGranularityInDays":1,"blobType":["blockBlob"]}}}'
73+
headers:
74+
cache-control:
75+
- no-cache
76+
content-length:
77+
- '525'
78+
content-type:
79+
- application/json
80+
date:
81+
- Mon, 05 Jul 2021 08:26:56 GMT
82+
expires:
83+
- '-1'
84+
pragma:
85+
- no-cache
86+
server:
87+
- Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0
88+
strict-transport-security:
89+
- max-age=31536000; includeSubDomains
90+
transfer-encoding:
91+
- chunked
92+
vary:
93+
- Accept-Encoding
94+
x-content-type-options:
95+
- nosniff
96+
x-ms-ratelimit-remaining-subscription-writes:
97+
- '1198'
98+
status:
99+
code: 200
100+
message: OK
101+
- request:
102+
body: null
103+
headers:
104+
Accept:
105+
- application/json
106+
Accept-Encoding:
107+
- gzip, deflate
108+
CommandName:
109+
- storage account blob-service-properties show
110+
Connection:
111+
- keep-alive
112+
ParameterSetName:
113+
- -n -g
114+
User-Agent:
115+
- AZURECLI/2.26.0 azsdk-python-azure-mgmt-storage/18.0.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
116+
method: GET
117+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_sa_versioning000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default?api-version=2021-04-01
118+
response:
119+
body:
120+
string: '{"sku":{"name":"Standard_LRS","tier":"Standard"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_sa_versioning000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default","name":"default","type":"Microsoft.Storage/storageAccounts/blobServices","properties":{"cors":{"corsRules":[]},"deleteRetentionPolicy":{"enabled":false},"lastAccessTimeTrackingPolicy":{"enable":true,"name":"AccessTimeTracking","trackingGranularityInDays":1,"blobType":["blockBlob"]}}}'
121+
headers:
122+
cache-control:
123+
- no-cache
124+
content-length:
125+
- '573'
126+
content-type:
127+
- application/json
128+
date:
129+
- Mon, 05 Jul 2021 08:26:57 GMT
130+
expires:
131+
- '-1'
132+
pragma:
133+
- no-cache
134+
server:
135+
- Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0
136+
strict-transport-security:
137+
- max-age=31536000; includeSubDomains
138+
transfer-encoding:
139+
- chunked
140+
vary:
141+
- Accept-Encoding
142+
x-content-type-options:
143+
- nosniff
144+
status:
145+
code: 200
146+
message: OK
147+
- request:
148+
body: null
149+
headers:
150+
Accept:
151+
- application/json
152+
Accept-Encoding:
153+
- gzip, deflate
154+
CommandName:
155+
- storage account blob-service-properties update
156+
Connection:
157+
- keep-alive
158+
ParameterSetName:
159+
- --enable-last-access-tracking -n -g
160+
User-Agent:
161+
- AZURECLI/2.26.0 azsdk-python-azure-mgmt-storage/18.0.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
162+
method: GET
163+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_sa_versioning000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default?api-version=2021-04-01
164+
response:
165+
body:
166+
string: '{"sku":{"name":"Standard_LRS","tier":"Standard"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_sa_versioning000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default","name":"default","type":"Microsoft.Storage/storageAccounts/blobServices","properties":{"cors":{"corsRules":[]},"deleteRetentionPolicy":{"enabled":false},"lastAccessTimeTrackingPolicy":{"enable":true,"name":"AccessTimeTracking","trackingGranularityInDays":1,"blobType":["blockBlob"]}}}'
167+
headers:
168+
cache-control:
169+
- no-cache
170+
content-length:
171+
- '573'
172+
content-type:
173+
- application/json
174+
date:
175+
- Mon, 05 Jul 2021 08:26:58 GMT
176+
expires:
177+
- '-1'
178+
pragma:
179+
- no-cache
180+
server:
181+
- Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0
182+
strict-transport-security:
183+
- max-age=31536000; includeSubDomains
184+
transfer-encoding:
185+
- chunked
186+
vary:
187+
- Accept-Encoding
188+
x-content-type-options:
189+
- nosniff
190+
status:
191+
code: 200
192+
message: OK
193+
- request:
194+
body: '{"properties": {"cors": {"corsRules": []}, "deleteRetentionPolicy": {"enabled":
195+
false}, "lastAccessTimeTrackingPolicy": {"enable": false}}}'
196+
headers:
197+
Accept:
198+
- application/json
199+
Accept-Encoding:
200+
- gzip, deflate
201+
CommandName:
202+
- storage account blob-service-properties update
203+
Connection:
204+
- keep-alive
205+
Content-Length:
206+
- '139'
207+
Content-Type:
208+
- application/json
209+
ParameterSetName:
210+
- --enable-last-access-tracking -n -g
211+
User-Agent:
212+
- AZURECLI/2.26.0 azsdk-python-azure-mgmt-storage/18.0.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
213+
method: PUT
214+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_sa_versioning000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default?api-version=2021-04-01
215+
response:
216+
body:
217+
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_sa_versioning000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default","name":"default","type":"Microsoft.Storage/storageAccounts/blobServices","properties":{"cors":{"corsRules":[]},"deleteRetentionPolicy":{"enabled":false}}}'
218+
headers:
219+
cache-control:
220+
- no-cache
221+
content-length:
222+
- '395'
223+
content-type:
224+
- application/json
225+
date:
226+
- Mon, 05 Jul 2021 08:27:00 GMT
227+
expires:
228+
- '-1'
229+
pragma:
230+
- no-cache
231+
server:
232+
- Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0
233+
strict-transport-security:
234+
- max-age=31536000; includeSubDomains
235+
transfer-encoding:
236+
- chunked
237+
vary:
238+
- Accept-Encoding
239+
x-content-type-options:
240+
- nosniff
241+
x-ms-ratelimit-remaining-subscription-writes:
242+
- '1199'
243+
status:
244+
code: 200
245+
message: OK
246+
- request:
247+
body: null
248+
headers:
249+
Accept:
250+
- application/json
251+
Accept-Encoding:
252+
- gzip, deflate
253+
CommandName:
254+
- storage account blob-service-properties update
255+
Connection:
256+
- keep-alive
257+
ParameterSetName:
258+
- --enable-last-access-tracking -n -g
259+
User-Agent:
260+
- AZURECLI/2.26.0 azsdk-python-azure-mgmt-storage/18.0.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
261+
method: GET
262+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_sa_versioning000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default?api-version=2021-04-01
263+
response:
264+
body:
265+
string: '{"sku":{"name":"Standard_LRS","tier":"Standard"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_sa_versioning000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default","name":"default","type":"Microsoft.Storage/storageAccounts/blobServices","properties":{"cors":{"corsRules":[]},"deleteRetentionPolicy":{"enabled":false}}}'
266+
headers:
267+
cache-control:
268+
- no-cache
269+
content-length:
270+
- '443'
271+
content-type:
272+
- application/json
273+
date:
274+
- Mon, 05 Jul 2021 08:27:00 GMT
275+
expires:
276+
- '-1'
277+
pragma:
278+
- no-cache
279+
server:
280+
- Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0
281+
strict-transport-security:
282+
- max-age=31536000; includeSubDomains
283+
transfer-encoding:
284+
- chunked
285+
vary:
286+
- Accept-Encoding
287+
x-content-type-options:
288+
- nosniff
289+
status:
290+
code: 200
291+
message: OK
292+
- request:
293+
body: '{"properties": {"cors": {"corsRules": []}, "deleteRetentionPolicy": {"enabled":
294+
false}, "lastAccessTimeTrackingPolicy": {"enable": true}}}'
295+
headers:
296+
Accept:
297+
- application/json
298+
Accept-Encoding:
299+
- gzip, deflate
300+
CommandName:
301+
- storage account blob-service-properties update
302+
Connection:
303+
- keep-alive
304+
Content-Length:
305+
- '138'
306+
Content-Type:
307+
- application/json
308+
ParameterSetName:
309+
- --enable-last-access-tracking -n -g
310+
User-Agent:
311+
- AZURECLI/2.26.0 azsdk-python-azure-mgmt-storage/18.0.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
312+
method: PUT
313+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_sa_versioning000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default?api-version=2021-04-01
314+
response:
315+
body:
316+
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_sa_versioning000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default","name":"default","type":"Microsoft.Storage/storageAccounts/blobServices","properties":{"cors":{"corsRules":[]},"deleteRetentionPolicy":{"enabled":false},"lastAccessTimeTrackingPolicy":{"enable":true,"name":"AccessTimeTracking","trackingGranularityInDays":1,"blobType":["blockBlob"]}}}'
317+
headers:
318+
cache-control:
319+
- no-cache
320+
content-length:
321+
- '525'
322+
content-type:
323+
- application/json
324+
date:
325+
- Mon, 05 Jul 2021 08:27:01 GMT
326+
expires:
327+
- '-1'
328+
pragma:
329+
- no-cache
330+
server:
331+
- Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0
332+
strict-transport-security:
333+
- max-age=31536000; includeSubDomains
334+
transfer-encoding:
335+
- chunked
336+
vary:
337+
- Accept-Encoding
338+
x-content-type-options:
339+
- nosniff
340+
x-ms-ratelimit-remaining-subscription-writes:
341+
- '1199'
342+
status:
343+
code: 200
344+
message: OK
345+
- request:
346+
body: null
347+
headers:
348+
Accept:
349+
- application/json
350+
Accept-Encoding:
351+
- gzip, deflate
352+
CommandName:
353+
- storage account blob-service-properties show
354+
Connection:
355+
- keep-alive
356+
ParameterSetName:
357+
- -n -g
358+
User-Agent:
359+
- AZURECLI/2.26.0 azsdk-python-azure-mgmt-storage/18.0.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
360+
method: GET
361+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_sa_versioning000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default?api-version=2021-04-01
362+
response:
363+
body:
364+
string: '{"sku":{"name":"Standard_LRS","tier":"Standard"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_sa_versioning000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default","name":"default","type":"Microsoft.Storage/storageAccounts/blobServices","properties":{"cors":{"corsRules":[]},"deleteRetentionPolicy":{"enabled":false},"lastAccessTimeTrackingPolicy":{"enable":true,"name":"AccessTimeTracking","trackingGranularityInDays":1,"blobType":["blockBlob"]}}}'
365+
headers:
366+
cache-control:
367+
- no-cache
368+
content-length:
369+
- '573'
370+
content-type:
371+
- application/json
372+
date:
373+
- Mon, 05 Jul 2021 08:27:02 GMT
374+
expires:
375+
- '-1'
376+
pragma:
377+
- no-cache
378+
server:
379+
- Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0
380+
strict-transport-security:
381+
- max-age=31536000; includeSubDomains
382+
transfer-encoding:
383+
- chunked
384+
vary:
385+
- Accept-Encoding
386+
x-content-type-options:
387+
- nosniff
388+
status:
389+
code: 200
390+
message: OK
391+
version: 1

‎src/azure-cli/azure/cli/command_modules/storage/tests/latest/test_storage_account_scenarios.py

+27-1
Original file line numberDiff line numberDiff line change
@@ -1107,10 +1107,13 @@ def test_management_policy(self, resource_group, storage_account):
11071107
policy_file = os.path.join(curr_dir, 'mgmt_policy.json').replace('\\', '\\\\')
11081108

11091109
self.kwargs = {'rg': resource_group, 'sa': storage_account, 'policy': policy_file}
1110+
result = self.cmd('storage account blob-service-properties update --enable-last-access-tracking true -n {sa} -g {rg}').get_output_in_json()
1111+
self.assertEqual(result['lastAccessTimeTrackingPolicy']['enable'], True)
1112+
11101113
self.cmd('storage account management-policy create --account-name {sa} -g {rg} --policy @"{policy}"',
11111114
checks=[JMESPathCheck('policy.rules[0].name', 'olcmtest'),
11121115
JMESPathCheck('policy.rules[0].enabled', True),
1113-
JMESPathCheck('policy.rules[0].definition.actions.baseBlob.tierToCool.daysAfterModificationGreaterThan', 30),
1116+
JMESPathCheck('policy.rules[0].definition.actions.baseBlob.tierToCool.daysAfterLastAccessTimeGreaterThan', 30),
11141117
JMESPathCheck('policy.rules[0].definition.actions.baseBlob.tierToArchive.daysAfterModificationGreaterThan', 90),
11151118
JMESPathCheck('policy.rules[0].definition.actions.baseBlob.delete.daysAfterModificationGreaterThan', 1000),
11161119
JMESPathCheck('policy.rules[0].definition.actions.snapshot.tierToCool.daysAfterCreationGreaterThan', 30),
@@ -1588,6 +1591,29 @@ def test_storage_account_default_service_properties(self):
15881591
self.cmd('storage account blob-service-properties show -n {sa} -g {rg}',
15891592
checks=[self.check('defaultServiceVersion', '2018-11-09')])
15901593

1594+
@api_version_constraint(ResourceType.MGMT_STORAGE, min_api='2019-06-01')
1595+
@ResourceGroupPreparer(name_prefix="cli_test_sa_versioning")
1596+
@StorageAccountPreparer(location="eastus2", kind="StorageV2")
1597+
def test_storage_account_update_last_access(self):
1598+
result = self.cmd('storage account blob-service-properties update --enable-last-access-tracking true -n {sa} -g {rg}').get_output_in_json()
1599+
self.assertEqual(result['lastAccessTimeTrackingPolicy']['enable'], True)
1600+
1601+
result = self.cmd(
1602+
'storage account blob-service-properties show -n {sa} -g {rg}').get_output_in_json()
1603+
self.assertEqual(result['lastAccessTimeTrackingPolicy']['enable'], True)
1604+
self.assertEqual(result['lastAccessTimeTrackingPolicy']['name'], "AccessTimeTracking")
1605+
self.assertEqual(result['lastAccessTimeTrackingPolicy']['trackingGranularityInDays'], 1)
1606+
self.assertEqual(result['lastAccessTimeTrackingPolicy']['blobType'][0], "blockBlob")
1607+
1608+
result = self.cmd('storage account blob-service-properties update --enable-last-access-tracking false -n {sa} -g {rg}').get_output_in_json()
1609+
self.assertEqual(result['lastAccessTimeTrackingPolicy'], None)
1610+
1611+
result = self.cmd('storage account blob-service-properties update --enable-last-access-tracking -n {sa} -g {rg}').get_output_in_json()
1612+
self.assertEqual(result['lastAccessTimeTrackingPolicy']['enable'], True)
1613+
1614+
result = self.cmd('storage account blob-service-properties show -n {sa} -g {rg}').get_output_in_json()
1615+
self.assertEqual(result['lastAccessTimeTrackingPolicy']['enable'], True)
1616+
15911617

15921618
class FileServicePropertiesTests(StorageScenarioMixin, ScenarioTest):
15931619
@ResourceGroupPreparer(name_prefix='cli_file_soft_delete')

0 commit comments

Comments
 (0)
Please sign in to comment.