Azure / azure-cli

Azure Command-Line Interface
MIT License
4.02k stars 2.99k forks source link

CLI in not working for version parameter #16333

Open v-manish opened 3 years ago

v-manish commented 3 years ago

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

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

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

yonzhan commented 3 years ago

storage

ghost commented 3 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.

Issue Details
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**
Author: v-manish
Assignees: Juliehzl
Labels: `OKR3.2 Candidate`, `Service Attention`, `Storage`, `feature-request`
Milestone: S182
Juliehzl commented 3 years ago

Hi @v-manish, thanks for your feedback. You are right. CLI have to make sure there is SDK supported first.