summary import { ManagementPolicy , StorageManagementClient } from "@msinternal/storage-resource-manager" ; import { DefaultAzureCredential } from "@azure/identity" ; async function storageAccountSetManagementPolicies ( ) { const subscriptionId = "{subscription-id}" ; const resourceGroupName = "res7687" ; const accountName = "sto9699" ; const managementPolicyName = "default" ; const properties = { policy : { rules : [ { name : "olcmtest1" , type : "Lifecycle" , definition : { actions : { baseBlob : { delete : { daysAfterModificationGreaterThan : 1000 } , tierToArchive : { daysAfterModificationGreaterThan : 90 } , tierToCool : { daysAfterModificationGreaterThan : 30 } } , snapshot : { delete : { daysAfterCreationGreaterThan : 30 } } } , filters : { blobTypes : [ "blockBlob" ] , prefixMatch : [ "olcmtestcontainer1" ] } } , enabled : true } , { name : "olcmtest2" , type : "Lifecycle" , definition : { actions : { baseBlob : { delete : { daysAfterModificationGreaterThan : 1000 } , tierToArchive : { daysAfterModificationGreaterThan : 90 } , tierToCool : { daysAfterModificationGreaterThan : 30 } } } , filters : { blobIndexMatch : [ { name : "tag1" , op : "==" , value : "val1" } , { name : "tag2" , op : "==" , value : "val2" } ] , blobTypes : [ "blockBlob" ] , prefixMatch : [ "olcmtestcontainer2" ] } } , enabled : true } ] } } ; const credential = new DefaultAzureCredential ( ) ; const client = new StorageManagementClient ( credential , subscriptionId ) ; const result = await client . managementPolicies . createOrUpdate ( resourceGroupName , accountName , managementPolicyName , properties ) ; console . log ( result ) ; } storageAccountSetManagementPolicies ( ) . catch ( console . error ) ;