Azure / Azure/azure-cli

CLI in not working for version parameter

Open
#16,333 3 comments 0 reactions 1 assignee Claimed by @Juliehzl View on GitHub
act-codegen-extensibility-squad feature-request Need SDK released Service Attention Storage
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

When we are trying to enable the lifecycle management from the Azure portal, it is working for all the three subtypes base blobs, snapshots and versions, below is the screenshot:

![image](https://user-images.githubusercontent.com/76432901/102772844-37889300-43ae-11eb-8026-840d07cfed66.png)

Below is the code view for the same:
{
"rules": [
{
"enabled": true,
"name": "apsartest",
"type": "Lifecycle",
"definition": {
"actions": {
"version": {
"delete": {
"daysAfterCreationGreaterThan": 30
}
},
"baseBlob": {
"delete": {
"daysAfterModificationGreaterThan": 90
}
},
"snapshot": {
"delete": {
"daysAfterCreationGreaterThan": 60
}
}
},
"filters": {
"blobTypes": [
"blockBlob"
]
}
}
}
]
}

But when we try to update or create policy using CLI command , the version (Blob Subtype) is getting ignored ( i.e. LCM policy is getting created without Versions)

![image](https://user-images.githubusercontent.com/76432901/102772983-73bbf380-43ae-11eb-9703-33ca604ab452.png)

az storage account management-policy create --account-name 'apsareastus' --policy "policy.json" --resource-group 'mycommanresourcegroup'

It seems the root cause is that there is no API exposed in SDK to CLI.
As you can see in swagger, there is no version action defined in latest api version.

https://github.com/Azure/azure-rest-api-specs/blob/master/specification/storage/resource-manager/Microsoft.Storage/preview/2020-08-01-preview/storage.json#L3721-L3733

https://docs.microsoft.com/en-us/rest/api/storagerp/managementpolicies/createorupdate#managementpolicyschema

In the above REST API document, the version is defined at the top of the page as below:

But in the swagger definition, which is used to generate SDK for all languages, there is no definition for version in rule as you can see in https://github.com/Azure/azure-rest-api-specs/blob/master/specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/storage.json#L3334-L3344.

could you please provide an update or any work around how to use version parameter.

Thank you in advance.

> ### `az feedback` auto-generates most of the information requested below, as of CLI version 2.0.62

**Describe the bug**

**To Reproduce**

**Expected behavior**

**Environment summary**

**Additional context**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.