Sets the managementpolicy to the specified storage account.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/default?api-version=2023-01-01
URI Parameters
Name |
In |
Required |
Type |
Description |
accountName
|
path |
True
|
string
|
The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.
Regex pattern: ^[a-z0-9]+$
|
managementPolicyName
|
path |
True
|
ManagementPolicyName
|
The name of the Storage Account Management Policy. It should always be 'default'
|
resourceGroupName
|
path |
True
|
string
|
The name of the resource group within the user's subscription. The name is case insensitive.
Regex pattern: ^[-\w\._\(\)]+$
|
subscriptionId
|
path |
True
|
string
|
The ID of the target subscription.
|
api-version
|
query |
True
|
string
|
The API version to use for this operation.
|
Request Body
Responses
Name |
Type |
Description |
200 OK
|
ManagementPolicy
|
OK -- Put managementpolicy successfully.
|
Security
azure_auth
Azure Active Directory OAuth2 Flow
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name |
Description |
user_impersonation
|
impersonate your user account
|
Examples
StorageAccountSetManagementPolicies
Sample Request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/res7687/providers/Microsoft.Storage/storageAccounts/sto9699/managementPolicies/default?api-version=2023-01-01
{
"properties": {
"policy": {
"rules": [
{
"enabled": true,
"name": "olcmtest1",
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [
"blockBlob"
],
"prefixMatch": [
"olcmtestcontainer1"
]
},
"actions": {
"baseBlob": {
"tierToCool": {
"daysAfterModificationGreaterThan": 30
},
"tierToArchive": {
"daysAfterModificationGreaterThan": 90
},
"delete": {
"daysAfterModificationGreaterThan": 1000
}
},
"snapshot": {
"delete": {
"daysAfterCreationGreaterThan": 30
}
}
}
}
},
{
"enabled": true,
"name": "olcmtest2",
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [
"blockBlob"
],
"prefixMatch": [
"olcmtestcontainer2"
],
"blobIndexMatch": [
{
"name": "tag1",
"op": "==",
"value": "val1"
},
{
"name": "tag2",
"op": "==",
"value": "val2"
}
]
},
"actions": {
"baseBlob": {
"tierToCool": {
"daysAfterModificationGreaterThan": 30
},
"tierToArchive": {
"daysAfterModificationGreaterThan": 90
},
"delete": {
"daysAfterModificationGreaterThan": 1000
}
}
}
}
}
]
}
}
}
import com.azure.resourcemanager.storage.fluent.models.ManagementPolicyInner;
import com.azure.resourcemanager.storage.models.DateAfterCreation;
import com.azure.resourcemanager.storage.models.DateAfterModification;
import com.azure.resourcemanager.storage.models.ManagementPolicyAction;
import com.azure.resourcemanager.storage.models.ManagementPolicyBaseBlob;
import com.azure.resourcemanager.storage.models.ManagementPolicyDefinition;
import com.azure.resourcemanager.storage.models.ManagementPolicyFilter;
import com.azure.resourcemanager.storage.models.ManagementPolicyName;
import com.azure.resourcemanager.storage.models.ManagementPolicyRule;
import com.azure.resourcemanager.storage.models.ManagementPolicySchema;
import com.azure.resourcemanager.storage.models.ManagementPolicySnapShot;
import com.azure.resourcemanager.storage.models.RuleType;
import com.azure.resourcemanager.storage.models.TagFilter;
import java.util.Arrays;
/** Samples for ManagementPolicies CreateOrUpdate. */
public final class Main {
/*
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/
* StorageAccountSetManagementPolicy.json
*/
/**
* Sample code: StorageAccountSetManagementPolicies.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void storageAccountSetManagementPolicies(com.azure.resourcemanager.AzureResourceManager azure) {
azure.storageAccounts().manager().serviceClient().getManagementPolicies()
.createOrUpdateWithResponse("res7687", "sto9699", ManagementPolicyName.DEFAULT,
new ManagementPolicyInner()
.withPolicy(
new ManagementPolicySchema().withRules(
Arrays.asList(
new ManagementPolicyRule().withEnabled(true).withName("olcmtest1")
.withType(RuleType.LIFECYCLE)
.withDefinition(new ManagementPolicyDefinition()
.withActions(new ManagementPolicyAction()
.withBaseBlob(new ManagementPolicyBaseBlob()
.withTierToCool(new DateAfterModification()
.withDaysAfterModificationGreaterThan(30.0F))
.withTierToArchive(new DateAfterModification()
.withDaysAfterModificationGreaterThan(90.0F))
.withDelete(new DateAfterModification()
.withDaysAfterModificationGreaterThan(1000.0F)))
.withSnapshot(new ManagementPolicySnapShot().withDelete(
new DateAfterCreation().withDaysAfterCreationGreaterThan(30f))))
.withFilters(new ManagementPolicyFilter()
.withPrefixMatch(Arrays.asList("olcmtestcontainer1"))
.withBlobTypes(Arrays.asList("blockBlob")))),
new ManagementPolicyRule().withEnabled(true).withName("olcmtest2")
.withType(RuleType.LIFECYCLE)
.withDefinition(new ManagementPolicyDefinition()
.withActions(
new ManagementPolicyAction().withBaseBlob(new ManagementPolicyBaseBlob()
.withTierToCool(new DateAfterModification()
.withDaysAfterModificationGreaterThan(30.0F))
.withTierToArchive(new DateAfterModification()
.withDaysAfterModificationGreaterThan(90.0F))
.withDelete(new DateAfterModification()
.withDaysAfterModificationGreaterThan(1000.0F))))
.withFilters(new ManagementPolicyFilter()
.withPrefixMatch(Arrays.asList("olcmtestcontainer2"))
.withBlobTypes(Arrays.asList("blockBlob"))
.withBlobIndexMatch(Arrays.asList(
new TagFilter().withName("tag1").withOp("==").withValue("val1"),
new TagFilter().withName("tag2").withOp("==").withValue("val2")))))))),
com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.storage import StorageManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-storage
# USAGE
python storage_account_set_management_policy.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = StorageManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.management_policies.create_or_update(
resource_group_name="res7687",
account_name="sto9699",
management_policy_name="default",
properties={
"properties": {
"policy": {
"rules": [
{
"definition": {
"actions": {
"baseBlob": {
"delete": {"daysAfterModificationGreaterThan": 1000},
"tierToArchive": {"daysAfterModificationGreaterThan": 90},
"tierToCool": {"daysAfterModificationGreaterThan": 30},
},
"snapshot": {"delete": {"daysAfterCreationGreaterThan": 30}},
},
"filters": {"blobTypes": ["blockBlob"], "prefixMatch": ["olcmtestcontainer1"]},
},
"enabled": True,
"name": "olcmtest1",
"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,
"name": "olcmtest2",
"type": "Lifecycle",
},
]
}
}
},
)
print(response)
# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicy.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armstorage_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0baf811c3c76c87b3c127d098519bd97141222dd/specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicy.json
func ExampleManagementPoliciesClient_CreateOrUpdate_storageAccountSetManagementPolicies() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armstorage.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewManagementPoliciesClient().CreateOrUpdate(ctx, "res7687", "sto9699", armstorage.ManagementPolicyNameDefault, armstorage.ManagementPolicy{
Properties: &armstorage.ManagementPolicyProperties{
Policy: &armstorage.ManagementPolicySchema{
Rules: []*armstorage.ManagementPolicyRule{
{
Name: to.Ptr("olcmtest1"),
Type: to.Ptr(armstorage.RuleTypeLifecycle),
Definition: &armstorage.ManagementPolicyDefinition{
Actions: &armstorage.ManagementPolicyAction{
BaseBlob: &armstorage.ManagementPolicyBaseBlob{
Delete: &armstorage.DateAfterModification{
DaysAfterModificationGreaterThan: to.Ptr[float32](1000),
},
TierToArchive: &armstorage.DateAfterModification{
DaysAfterModificationGreaterThan: to.Ptr[float32](90),
},
TierToCool: &armstorage.DateAfterModification{
DaysAfterModificationGreaterThan: to.Ptr[float32](30),
},
},
Snapshot: &armstorage.ManagementPolicySnapShot{
Delete: &armstorage.DateAfterCreation{
DaysAfterCreationGreaterThan: to.Ptr[float32](30),
},
},
},
Filters: &armstorage.ManagementPolicyFilter{
BlobTypes: []*string{
to.Ptr("blockBlob")},
PrefixMatch: []*string{
to.Ptr("olcmtestcontainer1")},
},
},
Enabled: to.Ptr(true),
},
{
Name: to.Ptr("olcmtest2"),
Type: to.Ptr(armstorage.RuleTypeLifecycle),
Definition: &armstorage.ManagementPolicyDefinition{
Actions: &armstorage.ManagementPolicyAction{
BaseBlob: &armstorage.ManagementPolicyBaseBlob{
Delete: &armstorage.DateAfterModification{
DaysAfterModificationGreaterThan: to.Ptr[float32](1000),
},
TierToArchive: &armstorage.DateAfterModification{
DaysAfterModificationGreaterThan: to.Ptr[float32](90),
},
TierToCool: &armstorage.DateAfterModification{
DaysAfterModificationGreaterThan: to.Ptr[float32](30),
},
},
},
Filters: &armstorage.ManagementPolicyFilter{
BlobIndexMatch: []*armstorage.TagFilter{
{
Name: to.Ptr("tag1"),
Op: to.Ptr("=="),
Value: to.Ptr("val1"),
},
{
Name: to.Ptr("tag2"),
Op: to.Ptr("=="),
Value: to.Ptr("val2"),
}},
BlobTypes: []*string{
to.Ptr("blockBlob")},
PrefixMatch: []*string{
to.Ptr("olcmtestcontainer2")},
},
},
Enabled: to.Ptr(true),
}},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.ManagementPolicy = armstorage.ManagementPolicy{
// Name: to.Ptr("DefaultManagementPolicy"),
// Type: to.Ptr("Microsoft.Storage/storageAccounts/managementPolicies"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Storage/storageAccounts/sto288/managementPolicies/default"),
// Properties: &armstorage.ManagementPolicyProperties{
// LastModifiedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-08T02:53:39.093Z"); return t}()),
// Policy: &armstorage.ManagementPolicySchema{
// Rules: []*armstorage.ManagementPolicyRule{
// {
// Name: to.Ptr("olcmtest1"),
// Type: to.Ptr(armstorage.RuleTypeLifecycle),
// Definition: &armstorage.ManagementPolicyDefinition{
// Actions: &armstorage.ManagementPolicyAction{
// BaseBlob: &armstorage.ManagementPolicyBaseBlob{
// Delete: &armstorage.DateAfterModification{
// DaysAfterModificationGreaterThan: to.Ptr[float32](1000),
// },
// TierToArchive: &armstorage.DateAfterModification{
// DaysAfterModificationGreaterThan: to.Ptr[float32](90),
// },
// TierToCool: &armstorage.DateAfterModification{
// DaysAfterModificationGreaterThan: to.Ptr[float32](30),
// },
// },
// Snapshot: &armstorage.ManagementPolicySnapShot{
// Delete: &armstorage.DateAfterCreation{
// DaysAfterCreationGreaterThan: to.Ptr[float32](30),
// },
// },
// },
// Filters: &armstorage.ManagementPolicyFilter{
// BlobTypes: []*string{
// to.Ptr("blockBlob")},
// PrefixMatch: []*string{
// to.Ptr("olcmtestcontainer1")},
// },
// },
// Enabled: to.Ptr(true),
// },
// {
// Name: to.Ptr("olcmtest2"),
// Type: to.Ptr(armstorage.RuleTypeLifecycle),
// Definition: &armstorage.ManagementPolicyDefinition{
// Actions: &armstorage.ManagementPolicyAction{
// BaseBlob: &armstorage.ManagementPolicyBaseBlob{
// Delete: &armstorage.DateAfterModification{
// DaysAfterModificationGreaterThan: to.Ptr[float32](1000),
// },
// TierToArchive: &armstorage.DateAfterModification{
// DaysAfterModificationGreaterThan: to.Ptr[float32](90),
// },
// TierToCool: &armstorage.DateAfterModification{
// DaysAfterModificationGreaterThan: to.Ptr[float32](30),
// },
// },
// },
// Filters: &armstorage.ManagementPolicyFilter{
// BlobIndexMatch: []*armstorage.TagFilter{
// {
// Name: to.Ptr("tag1"),
// Op: to.Ptr("=="),
// Value: to.Ptr("val1"),
// },
// {
// Name: to.Ptr("tag2"),
// Op: to.Ptr("=="),
// Value: to.Ptr("val2"),
// }},
// BlobTypes: []*string{
// to.Ptr("blockBlob")},
// PrefixMatch: []*string{
// to.Ptr("olcmtestcontainer2")},
// },
// },
// Enabled: to.Ptr(true),
// }},
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { StorageManagementClient } = require("@azure/arm-storage");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Sets the managementpolicy to the specified storage account.
*
* @summary Sets the managementpolicy to the specified storage account.
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicy.json
*/
async function storageAccountSetManagementPolicies() {
const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "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);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Storage/storageAccounts/sto288/managementPolicies/default",
"name": "DefaultManagementPolicy",
"type": "Microsoft.Storage/storageAccounts/managementPolicies",
"properties": {
"policy": {
"rules": [
{
"enabled": true,
"name": "olcmtest1",
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [
"blockBlob"
],
"prefixMatch": [
"olcmtestcontainer1"
]
},
"actions": {
"baseBlob": {
"tierToCool": {
"daysAfterModificationGreaterThan": 30
},
"tierToArchive": {
"daysAfterModificationGreaterThan": 90
},
"delete": {
"daysAfterModificationGreaterThan": 1000
}
},
"snapshot": {
"delete": {
"daysAfterCreationGreaterThan": 30
}
}
}
}
},
{
"enabled": true,
"name": "olcmtest2",
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [
"blockBlob"
],
"prefixMatch": [
"olcmtestcontainer2"
],
"blobIndexMatch": [
{
"name": "tag1",
"op": "==",
"value": "val1"
},
{
"name": "tag2",
"op": "==",
"value": "val2"
}
]
},
"actions": {
"baseBlob": {
"tierToCool": {
"daysAfterModificationGreaterThan": 30
},
"tierToArchive": {
"daysAfterModificationGreaterThan": 90
},
"delete": {
"daysAfterModificationGreaterThan": 1000
}
}
}
}
}
]
},
"lastModifiedTime": "2018-06-08T02:53:39.0932539Z"
}
}
StorageAccountSetManagementPolicy_BaseBlobDaysAfterCreationActions
Sample Request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/res7687/providers/Microsoft.Storage/storageAccounts/sto9699/managementPolicies/default?api-version=2023-01-01
{
"properties": {
"policy": {
"rules": [
{
"enabled": true,
"name": "olcmtest1",
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [
"blockBlob"
],
"prefixMatch": [
"olcmtestcontainer1"
]
},
"actions": {
"baseBlob": {
"tierToCool": {
"daysAfterCreationGreaterThan": 30
},
"tierToArchive": {
"daysAfterCreationGreaterThan": 90
},
"delete": {
"daysAfterCreationGreaterThan": 1000
}
}
}
}
}
]
}
}
}
import com.azure.resourcemanager.storage.fluent.models.ManagementPolicyInner;
import com.azure.resourcemanager.storage.models.DateAfterModification;
import com.azure.resourcemanager.storage.models.ManagementPolicyAction;
import com.azure.resourcemanager.storage.models.ManagementPolicyBaseBlob;
import com.azure.resourcemanager.storage.models.ManagementPolicyDefinition;
import com.azure.resourcemanager.storage.models.ManagementPolicyFilter;
import com.azure.resourcemanager.storage.models.ManagementPolicyName;
import com.azure.resourcemanager.storage.models.ManagementPolicyRule;
import com.azure.resourcemanager.storage.models.ManagementPolicySchema;
import com.azure.resourcemanager.storage.models.RuleType;
import java.util.Arrays;
/** Samples for ManagementPolicies CreateOrUpdate. */
public final class Main {
/*
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/
* StorageAccountSetManagementPolicy_BaseBlobDaysAfterCreationActions.json
*/
/**
* Sample code: StorageAccountSetManagementPolicy_BaseBlobDaysAfterCreationActions.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void storageAccountSetManagementPolicyBaseBlobDaysAfterCreationActions(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.storageAccounts().manager().serviceClient().getManagementPolicies()
.createOrUpdateWithResponse("res7687", "sto9699", ManagementPolicyName.DEFAULT,
new ManagementPolicyInner()
.withPolicy(
new ManagementPolicySchema()
.withRules(
Arrays
.asList(new ManagementPolicyRule().withEnabled(true).withName("olcmtest1")
.withType(RuleType.LIFECYCLE)
.withDefinition(new ManagementPolicyDefinition()
.withActions(
new ManagementPolicyAction().withBaseBlob(new ManagementPolicyBaseBlob()
.withTierToCool(new DateAfterModification()
.withDaysAfterCreationGreaterThan(30.0F))
.withTierToArchive(new DateAfterModification()
.withDaysAfterCreationGreaterThan(90.0F))
.withDelete(new DateAfterModification()
.withDaysAfterCreationGreaterThan(1000.0F))))
.withFilters(new ManagementPolicyFilter()
.withPrefixMatch(Arrays.asList("olcmtestcontainer1"))
.withBlobTypes(Arrays.asList("blockBlob"))))))),
com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.storage import StorageManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-storage
# USAGE
python storage_account_set_management_policy_base_blob_days_after_creation_actions.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = StorageManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.management_policies.create_or_update(
resource_group_name="res7687",
account_name="sto9699",
management_policy_name="default",
properties={
"properties": {
"policy": {
"rules": [
{
"definition": {
"actions": {
"baseBlob": {
"delete": {"daysAfterCreationGreaterThan": 1000},
"tierToArchive": {"daysAfterCreationGreaterThan": 90},
"tierToCool": {"daysAfterCreationGreaterThan": 30},
}
},
"filters": {"blobTypes": ["blockBlob"], "prefixMatch": ["olcmtestcontainer1"]},
},
"enabled": True,
"name": "olcmtest1",
"type": "Lifecycle",
}
]
}
}
},
)
print(response)
# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicy_BaseBlobDaysAfterCreationActions.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armstorage_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0baf811c3c76c87b3c127d098519bd97141222dd/specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicy_BaseBlobDaysAfterCreationActions.json
func ExampleManagementPoliciesClient_CreateOrUpdate_storageAccountSetManagementPolicyBaseBlobDaysAfterCreationActions() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armstorage.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewManagementPoliciesClient().CreateOrUpdate(ctx, "res7687", "sto9699", armstorage.ManagementPolicyNameDefault, armstorage.ManagementPolicy{
Properties: &armstorage.ManagementPolicyProperties{
Policy: &armstorage.ManagementPolicySchema{
Rules: []*armstorage.ManagementPolicyRule{
{
Name: to.Ptr("olcmtest1"),
Type: to.Ptr(armstorage.RuleTypeLifecycle),
Definition: &armstorage.ManagementPolicyDefinition{
Actions: &armstorage.ManagementPolicyAction{
BaseBlob: &armstorage.ManagementPolicyBaseBlob{
Delete: &armstorage.DateAfterModification{
DaysAfterCreationGreaterThan: to.Ptr[float32](1000),
},
TierToArchive: &armstorage.DateAfterModification{
DaysAfterCreationGreaterThan: to.Ptr[float32](90),
},
TierToCool: &armstorage.DateAfterModification{
DaysAfterCreationGreaterThan: to.Ptr[float32](30),
},
},
},
Filters: &armstorage.ManagementPolicyFilter{
BlobTypes: []*string{
to.Ptr("blockBlob")},
PrefixMatch: []*string{
to.Ptr("olcmtestcontainer1")},
},
},
Enabled: to.Ptr(true),
}},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.ManagementPolicy = armstorage.ManagementPolicy{
// Name: to.Ptr("DefaultManagementPolicy"),
// Type: to.Ptr("Microsoft.Storage/storageAccounts/managementPolicies"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Storage/storageAccounts/sto288/managementPolicies/default"),
// Properties: &armstorage.ManagementPolicyProperties{
// LastModifiedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-08T02:53:39.093Z"); return t}()),
// Policy: &armstorage.ManagementPolicySchema{
// Rules: []*armstorage.ManagementPolicyRule{
// {
// Name: to.Ptr("olcmtest1"),
// Type: to.Ptr(armstorage.RuleTypeLifecycle),
// Definition: &armstorage.ManagementPolicyDefinition{
// Actions: &armstorage.ManagementPolicyAction{
// BaseBlob: &armstorage.ManagementPolicyBaseBlob{
// Delete: &armstorage.DateAfterModification{
// DaysAfterCreationGreaterThan: to.Ptr[float32](1000),
// },
// TierToArchive: &armstorage.DateAfterModification{
// DaysAfterCreationGreaterThan: to.Ptr[float32](90),
// },
// TierToCool: &armstorage.DateAfterModification{
// DaysAfterCreationGreaterThan: to.Ptr[float32](30),
// },
// },
// },
// Filters: &armstorage.ManagementPolicyFilter{
// BlobTypes: []*string{
// to.Ptr("blockBlob")},
// PrefixMatch: []*string{
// to.Ptr("olcmtestcontainer1")},
// },
// },
// Enabled: to.Ptr(true),
// }},
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { StorageManagementClient } = require("@azure/arm-storage");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Sets the managementpolicy to the specified storage account.
*
* @summary Sets the managementpolicy to the specified storage account.
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicy_BaseBlobDaysAfterCreationActions.json
*/
async function storageAccountSetManagementPolicyBaseBlobDaysAfterCreationActions() {
const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687";
const accountName = "sto9699";
const managementPolicyName = "default";
const properties = {
policy: {
rules: [
{
name: "olcmtest1",
type: "Lifecycle",
definition: {
actions: {
baseBlob: {
delete: { daysAfterCreationGreaterThan: 1000 },
tierToArchive: { daysAfterCreationGreaterThan: 90 },
tierToCool: { daysAfterCreationGreaterThan: 30 },
},
},
filters: {
blobTypes: ["blockBlob"],
prefixMatch: ["olcmtestcontainer1"],
},
},
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);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Storage/storageAccounts/sto288/managementPolicies/default",
"name": "DefaultManagementPolicy",
"type": "Microsoft.Storage/storageAccounts/managementPolicies",
"properties": {
"policy": {
"rules": [
{
"enabled": true,
"name": "olcmtest1",
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [
"blockBlob"
],
"prefixMatch": [
"olcmtestcontainer1"
]
},
"actions": {
"baseBlob": {
"tierToCool": {
"daysAfterCreationGreaterThan": 30
},
"tierToArchive": {
"daysAfterCreationGreaterThan": 90
},
"delete": {
"daysAfterCreationGreaterThan": 1000
}
}
}
}
}
]
},
"lastModifiedTime": "2021-06-08T02:53:39.0932539Z"
}
}
StorageAccountSetManagementPolicy_LastAccessTimeBasedBlobActions
Sample Request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/res7687/providers/Microsoft.Storage/storageAccounts/sto9699/managementPolicies/default?api-version=2023-01-01
{
"properties": {
"policy": {
"rules": [
{
"enabled": true,
"name": "olcmtest",
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [
"blockBlob"
],
"prefixMatch": [
"olcmtestcontainer"
]
},
"actions": {
"baseBlob": {
"tierToCool": {
"daysAfterLastAccessTimeGreaterThan": 30
},
"tierToArchive": {
"daysAfterLastAccessTimeGreaterThan": 90
},
"delete": {
"daysAfterLastAccessTimeGreaterThan": 1000
},
"enableAutoTierToHotFromCool": true
},
"snapshot": {
"delete": {
"daysAfterCreationGreaterThan": 30
}
}
}
}
}
]
}
}
}
import com.azure.resourcemanager.storage.fluent.models.ManagementPolicyInner;
import com.azure.resourcemanager.storage.models.DateAfterCreation;
import com.azure.resourcemanager.storage.models.DateAfterModification;
import com.azure.resourcemanager.storage.models.ManagementPolicyAction;
import com.azure.resourcemanager.storage.models.ManagementPolicyBaseBlob;
import com.azure.resourcemanager.storage.models.ManagementPolicyDefinition;
import com.azure.resourcemanager.storage.models.ManagementPolicyFilter;
import com.azure.resourcemanager.storage.models.ManagementPolicyName;
import com.azure.resourcemanager.storage.models.ManagementPolicyRule;
import com.azure.resourcemanager.storage.models.ManagementPolicySchema;
import com.azure.resourcemanager.storage.models.ManagementPolicySnapShot;
import com.azure.resourcemanager.storage.models.RuleType;
import java.util.Arrays;
/** Samples for ManagementPolicies CreateOrUpdate. */
public final class Main {
/*
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/
* StorageAccountSetManagementPolicy_LastAccessTimeBasedBlobActions.json
*/
/**
* Sample code: StorageAccountSetManagementPolicy_LastAccessTimeBasedBlobActions.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void storageAccountSetManagementPolicyLastAccessTimeBasedBlobActions(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.storageAccounts().manager().serviceClient().getManagementPolicies()
.createOrUpdateWithResponse("res7687", "sto9699", ManagementPolicyName.DEFAULT,
new ManagementPolicyInner()
.withPolicy(
new ManagementPolicySchema()
.withRules(Arrays.asList(new ManagementPolicyRule().withEnabled(true).withName("olcmtest")
.withType(RuleType.LIFECYCLE)
.withDefinition(new ManagementPolicyDefinition()
.withActions(new ManagementPolicyAction()
.withBaseBlob(new ManagementPolicyBaseBlob()
.withTierToCool(new DateAfterModification()
.withDaysAfterLastAccessTimeGreaterThan(30.0F))
.withTierToArchive(new DateAfterModification()
.withDaysAfterLastAccessTimeGreaterThan(90.0F))
.withDelete(new DateAfterModification()
.withDaysAfterLastAccessTimeGreaterThan(1000.0F))
.withEnableAutoTierToHotFromCool(true))
.withSnapshot(new ManagementPolicySnapShot()
.withDelete(new DateAfterCreation().withDaysAfterCreationGreaterThan(30f))))
.withFilters(
new ManagementPolicyFilter().withPrefixMatch(Arrays.asList("olcmtestcontainer"))
.withBlobTypes(Arrays.asList("blockBlob"))))))),
com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.storage import StorageManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-storage
# USAGE
python storage_account_set_management_policy_last_access_time_based_blob_actions.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = StorageManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.management_policies.create_or_update(
resource_group_name="res7687",
account_name="sto9699",
management_policy_name="default",
properties={
"properties": {
"policy": {
"rules": [
{
"definition": {
"actions": {
"baseBlob": {
"delete": {"daysAfterLastAccessTimeGreaterThan": 1000},
"enableAutoTierToHotFromCool": True,
"tierToArchive": {"daysAfterLastAccessTimeGreaterThan": 90},
"tierToCool": {"daysAfterLastAccessTimeGreaterThan": 30},
},
"snapshot": {"delete": {"daysAfterCreationGreaterThan": 30}},
},
"filters": {"blobTypes": ["blockBlob"], "prefixMatch": ["olcmtestcontainer"]},
},
"enabled": True,
"name": "olcmtest",
"type": "Lifecycle",
}
]
}
}
},
)
print(response)
# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicy_LastAccessTimeBasedBlobActions.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armstorage_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0baf811c3c76c87b3c127d098519bd97141222dd/specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicy_LastAccessTimeBasedBlobActions.json
func ExampleManagementPoliciesClient_CreateOrUpdate_storageAccountSetManagementPolicyLastAccessTimeBasedBlobActions() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armstorage.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewManagementPoliciesClient().CreateOrUpdate(ctx, "res7687", "sto9699", armstorage.ManagementPolicyNameDefault, armstorage.ManagementPolicy{
Properties: &armstorage.ManagementPolicyProperties{
Policy: &armstorage.ManagementPolicySchema{
Rules: []*armstorage.ManagementPolicyRule{
{
Name: to.Ptr("olcmtest"),
Type: to.Ptr(armstorage.RuleTypeLifecycle),
Definition: &armstorage.ManagementPolicyDefinition{
Actions: &armstorage.ManagementPolicyAction{
BaseBlob: &armstorage.ManagementPolicyBaseBlob{
Delete: &armstorage.DateAfterModification{
DaysAfterLastAccessTimeGreaterThan: to.Ptr[float32](1000),
},
EnableAutoTierToHotFromCool: to.Ptr(true),
TierToArchive: &armstorage.DateAfterModification{
DaysAfterLastAccessTimeGreaterThan: to.Ptr[float32](90),
},
TierToCool: &armstorage.DateAfterModification{
DaysAfterLastAccessTimeGreaterThan: to.Ptr[float32](30),
},
},
Snapshot: &armstorage.ManagementPolicySnapShot{
Delete: &armstorage.DateAfterCreation{
DaysAfterCreationGreaterThan: to.Ptr[float32](30),
},
},
},
Filters: &armstorage.ManagementPolicyFilter{
BlobTypes: []*string{
to.Ptr("blockBlob")},
PrefixMatch: []*string{
to.Ptr("olcmtestcontainer")},
},
},
Enabled: to.Ptr(true),
}},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.ManagementPolicy = armstorage.ManagementPolicy{
// Name: to.Ptr("DefaultManagementPolicy"),
// Type: to.Ptr("Microsoft.Storage/storageAccounts/managementPolicies"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Storage/storageAccounts/sto288/managementPolicies/default"),
// Properties: &armstorage.ManagementPolicyProperties{
// LastModifiedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-08T02:53:39.093Z"); return t}()),
// Policy: &armstorage.ManagementPolicySchema{
// Rules: []*armstorage.ManagementPolicyRule{
// {
// Name: to.Ptr("olcmtest"),
// Type: to.Ptr(armstorage.RuleTypeLifecycle),
// Definition: &armstorage.ManagementPolicyDefinition{
// Actions: &armstorage.ManagementPolicyAction{
// BaseBlob: &armstorage.ManagementPolicyBaseBlob{
// Delete: &armstorage.DateAfterModification{
// DaysAfterLastAccessTimeGreaterThan: to.Ptr[float32](1000),
// },
// EnableAutoTierToHotFromCool: to.Ptr(true),
// TierToArchive: &armstorage.DateAfterModification{
// DaysAfterLastAccessTimeGreaterThan: to.Ptr[float32](90),
// },
// TierToCool: &armstorage.DateAfterModification{
// DaysAfterLastAccessTimeGreaterThan: to.Ptr[float32](30),
// },
// },
// Snapshot: &armstorage.ManagementPolicySnapShot{
// Delete: &armstorage.DateAfterCreation{
// DaysAfterCreationGreaterThan: to.Ptr[float32](30),
// },
// },
// },
// Filters: &armstorage.ManagementPolicyFilter{
// BlobTypes: []*string{
// to.Ptr("blockBlob")},
// PrefixMatch: []*string{
// to.Ptr("olcmtestcontainer")},
// },
// },
// Enabled: to.Ptr(true),
// }},
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { StorageManagementClient } = require("@azure/arm-storage");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Sets the managementpolicy to the specified storage account.
*
* @summary Sets the managementpolicy to the specified storage account.
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicy_LastAccessTimeBasedBlobActions.json
*/
async function storageAccountSetManagementPolicyLastAccessTimeBasedBlobActions() {
const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687";
const accountName = "sto9699";
const managementPolicyName = "default";
const properties = {
policy: {
rules: [
{
name: "olcmtest",
type: "Lifecycle",
definition: {
actions: {
baseBlob: {
delete: { daysAfterLastAccessTimeGreaterThan: 1000 },
enableAutoTierToHotFromCool: true,
tierToArchive: { daysAfterLastAccessTimeGreaterThan: 90 },
tierToCool: { daysAfterLastAccessTimeGreaterThan: 30 },
},
snapshot: { delete: { daysAfterCreationGreaterThan: 30 } },
},
filters: {
blobTypes: ["blockBlob"],
prefixMatch: ["olcmtestcontainer"],
},
},
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);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Storage/storageAccounts/sto288/managementPolicies/default",
"name": "DefaultManagementPolicy",
"type": "Microsoft.Storage/storageAccounts/managementPolicies",
"properties": {
"policy": {
"rules": [
{
"enabled": true,
"name": "olcmtest",
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [
"blockBlob"
],
"prefixMatch": [
"olcmtestcontainer"
]
},
"actions": {
"baseBlob": {
"tierToCool": {
"daysAfterLastAccessTimeGreaterThan": 30
},
"tierToArchive": {
"daysAfterLastAccessTimeGreaterThan": 90
},
"delete": {
"daysAfterLastAccessTimeGreaterThan": 1000
},
"enableAutoTierToHotFromCool": true
},
"snapshot": {
"delete": {
"daysAfterCreationGreaterThan": 30
}
}
}
}
}
]
},
"lastModifiedTime": "2018-06-08T02:53:39.0932539Z"
}
}
StorageAccountSetManagementPolicy_LastTierChangeTimeActions
Sample Request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/res7687/providers/Microsoft.Storage/storageAccounts/sto9699/managementPolicies/default?api-version=2023-01-01
{
"properties": {
"policy": {
"rules": [
{
"enabled": true,
"name": "olcmtest",
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [
"blockBlob"
],
"prefixMatch": [
"olcmtestcontainer"
]
},
"actions": {
"baseBlob": {
"tierToCool": {
"daysAfterModificationGreaterThan": 30
},
"tierToArchive": {
"daysAfterModificationGreaterThan": 90,
"daysAfterLastTierChangeGreaterThan": 120
},
"delete": {
"daysAfterModificationGreaterThan": 1000
}
},
"snapshot": {
"tierToArchive": {
"daysAfterCreationGreaterThan": 30,
"daysAfterLastTierChangeGreaterThan": 90
}
},
"version": {
"tierToArchive": {
"daysAfterCreationGreaterThan": 30,
"daysAfterLastTierChangeGreaterThan": 90
}
}
}
}
}
]
}
}
}
import com.azure.resourcemanager.storage.fluent.models.ManagementPolicyInner;
import com.azure.resourcemanager.storage.models.DateAfterCreation;
import com.azure.resourcemanager.storage.models.DateAfterModification;
import com.azure.resourcemanager.storage.models.ManagementPolicyAction;
import com.azure.resourcemanager.storage.models.ManagementPolicyBaseBlob;
import com.azure.resourcemanager.storage.models.ManagementPolicyDefinition;
import com.azure.resourcemanager.storage.models.ManagementPolicyFilter;
import com.azure.resourcemanager.storage.models.ManagementPolicyName;
import com.azure.resourcemanager.storage.models.ManagementPolicyRule;
import com.azure.resourcemanager.storage.models.ManagementPolicySchema;
import com.azure.resourcemanager.storage.models.ManagementPolicySnapShot;
import com.azure.resourcemanager.storage.models.ManagementPolicyVersion;
import com.azure.resourcemanager.storage.models.RuleType;
import java.util.Arrays;
/** Samples for ManagementPolicies CreateOrUpdate. */
public final class Main {
/*
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/
* StorageAccountSetManagementPolicy_LastTierChangeTimeActions.json
*/
/**
* Sample code: StorageAccountSetManagementPolicy_LastTierChangeTimeActions.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void storageAccountSetManagementPolicyLastTierChangeTimeActions(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.storageAccounts().manager().serviceClient().getManagementPolicies()
.createOrUpdateWithResponse("res7687", "sto9699", ManagementPolicyName.DEFAULT,
new ManagementPolicyInner()
.withPolicy(
new ManagementPolicySchema()
.withRules(
Arrays.asList(new ManagementPolicyRule().withEnabled(true).withName("olcmtest")
.withType(RuleType.LIFECYCLE)
.withDefinition(new ManagementPolicyDefinition()
.withActions(new ManagementPolicyAction()
.withBaseBlob(new ManagementPolicyBaseBlob()
.withTierToCool(new DateAfterModification()
.withDaysAfterModificationGreaterThan(30.0F))
.withTierToArchive(new DateAfterModification()
.withDaysAfterModificationGreaterThan(90.0F)
.withDaysAfterLastTierChangeGreaterThan(120.0F))
.withDelete(new DateAfterModification()
.withDaysAfterModificationGreaterThan(1000.0F)))
.withSnapshot(new ManagementPolicySnapShot().withTierToArchive(
new DateAfterCreation().withDaysAfterCreationGreaterThan(30f)
.withDaysAfterLastTierChangeGreaterThan(90.0F)))
.withVersion(new ManagementPolicyVersion().withTierToArchive(
new DateAfterCreation().withDaysAfterCreationGreaterThan(30f)
.withDaysAfterLastTierChangeGreaterThan(90.0F))))
.withFilters(new ManagementPolicyFilter()
.withPrefixMatch(Arrays.asList("olcmtestcontainer"))
.withBlobTypes(Arrays.asList("blockBlob"))))))),
com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.storage import StorageManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-storage
# USAGE
python storage_account_set_management_policy_last_tier_change_time_actions.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = StorageManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.management_policies.create_or_update(
resource_group_name="res7687",
account_name="sto9699",
management_policy_name="default",
properties={
"properties": {
"policy": {
"rules": [
{
"definition": {
"actions": {
"baseBlob": {
"delete": {"daysAfterModificationGreaterThan": 1000},
"tierToArchive": {
"daysAfterLastTierChangeGreaterThan": 120,
"daysAfterModificationGreaterThan": 90,
},
"tierToCool": {"daysAfterModificationGreaterThan": 30},
},
"snapshot": {
"tierToArchive": {
"daysAfterCreationGreaterThan": 30,
"daysAfterLastTierChangeGreaterThan": 90,
}
},
"version": {
"tierToArchive": {
"daysAfterCreationGreaterThan": 30,
"daysAfterLastTierChangeGreaterThan": 90,
}
},
},
"filters": {"blobTypes": ["blockBlob"], "prefixMatch": ["olcmtestcontainer"]},
},
"enabled": True,
"name": "olcmtest",
"type": "Lifecycle",
}
]
}
}
},
)
print(response)
# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicy_LastTierChangeTimeActions.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armstorage_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0baf811c3c76c87b3c127d098519bd97141222dd/specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicy_LastTierChangeTimeActions.json
func ExampleManagementPoliciesClient_CreateOrUpdate_storageAccountSetManagementPolicyLastTierChangeTimeActions() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armstorage.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewManagementPoliciesClient().CreateOrUpdate(ctx, "res7687", "sto9699", armstorage.ManagementPolicyNameDefault, armstorage.ManagementPolicy{
Properties: &armstorage.ManagementPolicyProperties{
Policy: &armstorage.ManagementPolicySchema{
Rules: []*armstorage.ManagementPolicyRule{
{
Name: to.Ptr("olcmtest"),
Type: to.Ptr(armstorage.RuleTypeLifecycle),
Definition: &armstorage.ManagementPolicyDefinition{
Actions: &armstorage.ManagementPolicyAction{
BaseBlob: &armstorage.ManagementPolicyBaseBlob{
Delete: &armstorage.DateAfterModification{
DaysAfterModificationGreaterThan: to.Ptr[float32](1000),
},
TierToArchive: &armstorage.DateAfterModification{
DaysAfterLastTierChangeGreaterThan: to.Ptr[float32](120),
DaysAfterModificationGreaterThan: to.Ptr[float32](90),
},
TierToCool: &armstorage.DateAfterModification{
DaysAfterModificationGreaterThan: to.Ptr[float32](30),
},
},
Snapshot: &armstorage.ManagementPolicySnapShot{
TierToArchive: &armstorage.DateAfterCreation{
DaysAfterCreationGreaterThan: to.Ptr[float32](30),
DaysAfterLastTierChangeGreaterThan: to.Ptr[float32](90),
},
},
Version: &armstorage.ManagementPolicyVersion{
TierToArchive: &armstorage.DateAfterCreation{
DaysAfterCreationGreaterThan: to.Ptr[float32](30),
DaysAfterLastTierChangeGreaterThan: to.Ptr[float32](90),
},
},
},
Filters: &armstorage.ManagementPolicyFilter{
BlobTypes: []*string{
to.Ptr("blockBlob")},
PrefixMatch: []*string{
to.Ptr("olcmtestcontainer")},
},
},
Enabled: to.Ptr(true),
}},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.ManagementPolicy = armstorage.ManagementPolicy{
// Name: to.Ptr("DefaultManagementPolicy"),
// Type: to.Ptr("Microsoft.Storage/storageAccounts/managementPolicies"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Storage/storageAccounts/sto288/managementPolicies/default"),
// Properties: &armstorage.ManagementPolicyProperties{
// LastModifiedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-08T02:53:39.093Z"); return t}()),
// Policy: &armstorage.ManagementPolicySchema{
// Rules: []*armstorage.ManagementPolicyRule{
// {
// Name: to.Ptr("olcmtest"),
// Type: to.Ptr(armstorage.RuleTypeLifecycle),
// Definition: &armstorage.ManagementPolicyDefinition{
// Actions: &armstorage.ManagementPolicyAction{
// BaseBlob: &armstorage.ManagementPolicyBaseBlob{
// Delete: &armstorage.DateAfterModification{
// DaysAfterModificationGreaterThan: to.Ptr[float32](1000),
// },
// TierToArchive: &armstorage.DateAfterModification{
// DaysAfterLastTierChangeGreaterThan: to.Ptr[float32](120),
// DaysAfterModificationGreaterThan: to.Ptr[float32](90),
// },
// TierToCool: &armstorage.DateAfterModification{
// DaysAfterModificationGreaterThan: to.Ptr[float32](30),
// },
// },
// Snapshot: &armstorage.ManagementPolicySnapShot{
// TierToArchive: &armstorage.DateAfterCreation{
// DaysAfterCreationGreaterThan: to.Ptr[float32](30),
// DaysAfterLastTierChangeGreaterThan: to.Ptr[float32](90),
// },
// },
// Version: &armstorage.ManagementPolicyVersion{
// TierToArchive: &armstorage.DateAfterCreation{
// DaysAfterCreationGreaterThan: to.Ptr[float32](30),
// DaysAfterLastTierChangeGreaterThan: to.Ptr[float32](90),
// },
// },
// },
// Filters: &armstorage.ManagementPolicyFilter{
// BlobTypes: []*string{
// to.Ptr("blockBlob")},
// PrefixMatch: []*string{
// to.Ptr("olcmtestcontainer")},
// },
// },
// Enabled: to.Ptr(true),
// }},
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { StorageManagementClient } = require("@azure/arm-storage");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Sets the managementpolicy to the specified storage account.
*
* @summary Sets the managementpolicy to the specified storage account.
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicy_LastTierChangeTimeActions.json
*/
async function storageAccountSetManagementPolicyLastTierChangeTimeActions() {
const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687";
const accountName = "sto9699";
const managementPolicyName = "default";
const properties = {
policy: {
rules: [
{
name: "olcmtest",
type: "Lifecycle",
definition: {
actions: {
baseBlob: {
delete: { daysAfterModificationGreaterThan: 1000 },
tierToArchive: {
daysAfterLastTierChangeGreaterThan: 120,
daysAfterModificationGreaterThan: 90,
},
tierToCool: { daysAfterModificationGreaterThan: 30 },
},
snapshot: {
tierToArchive: {
daysAfterCreationGreaterThan: 30,
daysAfterLastTierChangeGreaterThan: 90,
},
},
version: {
tierToArchive: {
daysAfterCreationGreaterThan: 30,
daysAfterLastTierChangeGreaterThan: 90,
},
},
},
filters: {
blobTypes: ["blockBlob"],
prefixMatch: ["olcmtestcontainer"],
},
},
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);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Storage/storageAccounts/sto288/managementPolicies/default",
"name": "DefaultManagementPolicy",
"type": "Microsoft.Storage/storageAccounts/managementPolicies",
"properties": {
"policy": {
"rules": [
{
"enabled": true,
"name": "olcmtest",
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [
"blockBlob"
],
"prefixMatch": [
"olcmtestcontainer"
]
},
"actions": {
"baseBlob": {
"tierToCool": {
"daysAfterModificationGreaterThan": 30
},
"tierToArchive": {
"daysAfterModificationGreaterThan": 90,
"daysAfterLastTierChangeGreaterThan": 120
},
"delete": {
"daysAfterModificationGreaterThan": 1000
}
},
"snapshot": {
"tierToArchive": {
"daysAfterCreationGreaterThan": 30,
"daysAfterLastTierChangeGreaterThan": 90
}
},
"version": {
"tierToArchive": {
"daysAfterCreationGreaterThan": 30,
"daysAfterLastTierChangeGreaterThan": 90
}
}
}
}
}
]
},
"lastModifiedTime": "2018-06-08T02:53:39.0932539Z"
}
}
StorageAccountSetManagementPolicyColdTierActions
Sample Request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/res7687/providers/Microsoft.Storage/storageAccounts/sto9699/managementPolicies/default?api-version=2023-01-01
{
"properties": {
"policy": {
"rules": [
{
"enabled": true,
"name": "olcmtest1",
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [
"blockBlob"
],
"prefixMatch": [
"olcmtestcontainer1"
]
},
"actions": {
"baseBlob": {
"tierToCool": {
"daysAfterModificationGreaterThan": 30
},
"tierToArchive": {
"daysAfterModificationGreaterThan": 90
},
"tierToCold": {
"daysAfterModificationGreaterThan": 30
},
"delete": {
"daysAfterModificationGreaterThan": 1000
}
},
"snapshot": {
"tierToCold": {
"daysAfterCreationGreaterThan": 30
},
"delete": {
"daysAfterCreationGreaterThan": 30
}
},
"version": {
"tierToCold": {
"daysAfterCreationGreaterThan": 30
},
"delete": {
"daysAfterCreationGreaterThan": 30
}
}
}
}
}
]
}
}
}
import com.azure.resourcemanager.storage.fluent.models.ManagementPolicyInner;
import com.azure.resourcemanager.storage.models.DateAfterCreation;
import com.azure.resourcemanager.storage.models.DateAfterModification;
import com.azure.resourcemanager.storage.models.ManagementPolicyAction;
import com.azure.resourcemanager.storage.models.ManagementPolicyBaseBlob;
import com.azure.resourcemanager.storage.models.ManagementPolicyDefinition;
import com.azure.resourcemanager.storage.models.ManagementPolicyFilter;
import com.azure.resourcemanager.storage.models.ManagementPolicyName;
import com.azure.resourcemanager.storage.models.ManagementPolicyRule;
import com.azure.resourcemanager.storage.models.ManagementPolicySchema;
import com.azure.resourcemanager.storage.models.ManagementPolicySnapShot;
import com.azure.resourcemanager.storage.models.ManagementPolicyVersion;
import com.azure.resourcemanager.storage.models.RuleType;
import java.util.Arrays;
/** Samples for ManagementPolicies CreateOrUpdate. */
public final class Main {
/*
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/
* StorageAccountSetManagementPolicyColdTierActions.json
*/
/**
* Sample code: StorageAccountSetManagementPolicyColdTierActions.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
storageAccountSetManagementPolicyColdTierActions(com.azure.resourcemanager.AzureResourceManager azure) {
azure.storageAccounts().manager().serviceClient().getManagementPolicies()
.createOrUpdateWithResponse("res7687", "sto9699", ManagementPolicyName.DEFAULT,
new ManagementPolicyInner()
.withPolicy(
new ManagementPolicySchema()
.withRules(
Arrays.asList(new ManagementPolicyRule().withEnabled(true).withName("olcmtest1")
.withType(RuleType.LIFECYCLE)
.withDefinition(new ManagementPolicyDefinition()
.withActions(new ManagementPolicyAction()
.withBaseBlob(new ManagementPolicyBaseBlob()
.withTierToCool(new DateAfterModification()
.withDaysAfterModificationGreaterThan(30.0F))
.withTierToArchive(new DateAfterModification()
.withDaysAfterModificationGreaterThan(90.0F))
.withTierToCold(new DateAfterModification()
.withDaysAfterModificationGreaterThan(30.0F))
.withDelete(new DateAfterModification()
.withDaysAfterModificationGreaterThan(1000.0F)))
.withSnapshot(new ManagementPolicySnapShot()
.withTierToCold(
new DateAfterCreation().withDaysAfterCreationGreaterThan(30f))
.withDelete(
new DateAfterCreation().withDaysAfterCreationGreaterThan(30f)))
.withVersion(new ManagementPolicyVersion()
.withTierToCold(
new DateAfterCreation().withDaysAfterCreationGreaterThan(30f))
.withDelete(
new DateAfterCreation().withDaysAfterCreationGreaterThan(30f))))
.withFilters(new ManagementPolicyFilter()
.withPrefixMatch(Arrays.asList("olcmtestcontainer1"))
.withBlobTypes(Arrays.asList("blockBlob"))))))),
com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.storage import StorageManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-storage
# USAGE
python storage_account_set_management_policy_cold_tier_actions.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = StorageManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.management_policies.create_or_update(
resource_group_name="res7687",
account_name="sto9699",
management_policy_name="default",
properties={
"properties": {
"policy": {
"rules": [
{
"definition": {
"actions": {
"baseBlob": {
"delete": {"daysAfterModificationGreaterThan": 1000},
"tierToArchive": {"daysAfterModificationGreaterThan": 90},
"tierToCold": {"daysAfterModificationGreaterThan": 30},
"tierToCool": {"daysAfterModificationGreaterThan": 30},
},
"snapshot": {
"delete": {"daysAfterCreationGreaterThan": 30},
"tierToCold": {"daysAfterCreationGreaterThan": 30},
},
"version": {
"delete": {"daysAfterCreationGreaterThan": 30},
"tierToCold": {"daysAfterCreationGreaterThan": 30},
},
},
"filters": {"blobTypes": ["blockBlob"], "prefixMatch": ["olcmtestcontainer1"]},
},
"enabled": True,
"name": "olcmtest1",
"type": "Lifecycle",
}
]
}
}
},
)
print(response)
# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicyColdTierActions.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armstorage_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0baf811c3c76c87b3c127d098519bd97141222dd/specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicyColdTierActions.json
func ExampleManagementPoliciesClient_CreateOrUpdate_storageAccountSetManagementPolicyColdTierActions() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armstorage.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewManagementPoliciesClient().CreateOrUpdate(ctx, "res7687", "sto9699", armstorage.ManagementPolicyNameDefault, armstorage.ManagementPolicy{
Properties: &armstorage.ManagementPolicyProperties{
Policy: &armstorage.ManagementPolicySchema{
Rules: []*armstorage.ManagementPolicyRule{
{
Name: to.Ptr("olcmtest1"),
Type: to.Ptr(armstorage.RuleTypeLifecycle),
Definition: &armstorage.ManagementPolicyDefinition{
Actions: &armstorage.ManagementPolicyAction{
BaseBlob: &armstorage.ManagementPolicyBaseBlob{
Delete: &armstorage.DateAfterModification{
DaysAfterModificationGreaterThan: to.Ptr[float32](1000),
},
TierToArchive: &armstorage.DateAfterModification{
DaysAfterModificationGreaterThan: to.Ptr[float32](90),
},
TierToCold: &armstorage.DateAfterModification{
DaysAfterModificationGreaterThan: to.Ptr[float32](30),
},
TierToCool: &armstorage.DateAfterModification{
DaysAfterModificationGreaterThan: to.Ptr[float32](30),
},
},
Snapshot: &armstorage.ManagementPolicySnapShot{
Delete: &armstorage.DateAfterCreation{
DaysAfterCreationGreaterThan: to.Ptr[float32](30),
},
TierToCold: &armstorage.DateAfterCreation{
DaysAfterCreationGreaterThan: to.Ptr[float32](30),
},
},
Version: &armstorage.ManagementPolicyVersion{
Delete: &armstorage.DateAfterCreation{
DaysAfterCreationGreaterThan: to.Ptr[float32](30),
},
TierToCold: &armstorage.DateAfterCreation{
DaysAfterCreationGreaterThan: to.Ptr[float32](30),
},
},
},
Filters: &armstorage.ManagementPolicyFilter{
BlobTypes: []*string{
to.Ptr("blockBlob")},
PrefixMatch: []*string{
to.Ptr("olcmtestcontainer1")},
},
},
Enabled: to.Ptr(true),
}},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.ManagementPolicy = armstorage.ManagementPolicy{
// Name: to.Ptr("DefaultManagementPolicy"),
// Type: to.Ptr("Microsoft.Storage/storageAccounts/managementPolicies"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Storage/storageAccounts/sto288/managementPolicies/default"),
// Properties: &armstorage.ManagementPolicyProperties{
// LastModifiedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-08T02:53:39.093Z"); return t}()),
// Policy: &armstorage.ManagementPolicySchema{
// Rules: []*armstorage.ManagementPolicyRule{
// {
// Name: to.Ptr("olcmtest1"),
// Type: to.Ptr(armstorage.RuleTypeLifecycle),
// Definition: &armstorage.ManagementPolicyDefinition{
// Actions: &armstorage.ManagementPolicyAction{
// BaseBlob: &armstorage.ManagementPolicyBaseBlob{
// Delete: &armstorage.DateAfterModification{
// DaysAfterModificationGreaterThan: to.Ptr[float32](1000),
// },
// TierToArchive: &armstorage.DateAfterModification{
// DaysAfterModificationGreaterThan: to.Ptr[float32](90),
// },
// TierToCold: &armstorage.DateAfterModification{
// DaysAfterModificationGreaterThan: to.Ptr[float32](30),
// },
// TierToCool: &armstorage.DateAfterModification{
// DaysAfterModificationGreaterThan: to.Ptr[float32](30),
// },
// },
// Snapshot: &armstorage.ManagementPolicySnapShot{
// Delete: &armstorage.DateAfterCreation{
// DaysAfterCreationGreaterThan: to.Ptr[float32](30),
// },
// TierToCold: &armstorage.DateAfterCreation{
// DaysAfterCreationGreaterThan: to.Ptr[float32](30),
// },
// },
// Version: &armstorage.ManagementPolicyVersion{
// Delete: &armstorage.DateAfterCreation{
// DaysAfterCreationGreaterThan: to.Ptr[float32](30),
// },
// TierToCold: &armstorage.DateAfterCreation{
// DaysAfterCreationGreaterThan: to.Ptr[float32](30),
// },
// },
// },
// Filters: &armstorage.ManagementPolicyFilter{
// BlobTypes: []*string{
// to.Ptr("blockBlob")},
// PrefixMatch: []*string{
// to.Ptr("olcmtestcontainer1")},
// },
// },
// Enabled: to.Ptr(true),
// }},
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { StorageManagementClient } = require("@azure/arm-storage");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Sets the managementpolicy to the specified storage account.
*
* @summary Sets the managementpolicy to the specified storage account.
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicyColdTierActions.json
*/
async function storageAccountSetManagementPolicyColdTierActions() {
const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687";
const accountName = "sto9699";
const managementPolicyName = "default";
const properties = {
policy: {
rules: [
{
name: "olcmtest1",
type: "Lifecycle",
definition: {
actions: {
baseBlob: {
delete: { daysAfterModificationGreaterThan: 1000 },
tierToArchive: { daysAfterModificationGreaterThan: 90 },
tierToCold: { daysAfterModificationGreaterThan: 30 },
tierToCool: { daysAfterModificationGreaterThan: 30 },
},
snapshot: {
delete: { daysAfterCreationGreaterThan: 30 },
tierToCold: { daysAfterCreationGreaterThan: 30 },
},
version: {
delete: { daysAfterCreationGreaterThan: 30 },
tierToCold: { daysAfterCreationGreaterThan: 30 },
},
},
filters: {
blobTypes: ["blockBlob"],
prefixMatch: ["olcmtestcontainer1"],
},
},
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);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Storage/storageAccounts/sto288/managementPolicies/default",
"name": "DefaultManagementPolicy",
"type": "Microsoft.Storage/storageAccounts/managementPolicies",
"properties": {
"policy": {
"rules": [
{
"enabled": true,
"name": "olcmtest1",
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [
"blockBlob"
],
"prefixMatch": [
"olcmtestcontainer1"
]
},
"actions": {
"baseBlob": {
"tierToCool": {
"daysAfterModificationGreaterThan": 30
},
"tierToArchive": {
"daysAfterModificationGreaterThan": 90
},
"tierToCold": {
"daysAfterModificationGreaterThan": 30
},
"delete": {
"daysAfterModificationGreaterThan": 1000
}
},
"snapshot": {
"tierToCold": {
"daysAfterCreationGreaterThan": 30
},
"delete": {
"daysAfterCreationGreaterThan": 30
}
},
"version": {
"tierToCold": {
"daysAfterCreationGreaterThan": 30
},
"delete": {
"daysAfterCreationGreaterThan": 30
}
}
}
}
}
]
},
"lastModifiedTime": "2021-06-08T02:53:39.0932539Z"
}
}
StorageAccountSetManagementPolicyForBlockAndAppendBlobs
Sample Request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/res7687/providers/Microsoft.Storage/storageAccounts/sto9699/managementPolicies/default?api-version=2023-01-01
{
"properties": {
"policy": {
"rules": [
{
"enabled": true,
"name": "olcmtest1",
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [
"blockBlob",
"appendBlob"
],
"prefixMatch": [
"olcmtestcontainer1"
]
},
"actions": {
"baseBlob": {
"delete": {
"daysAfterModificationGreaterThan": 90
}
},
"snapshot": {
"delete": {
"daysAfterCreationGreaterThan": 90
}
},
"version": {
"delete": {
"daysAfterCreationGreaterThan": 90
}
}
}
}
}
]
}
}
}
import com.azure.resourcemanager.storage.fluent.models.ManagementPolicyInner;
import com.azure.resourcemanager.storage.models.DateAfterCreation;
import com.azure.resourcemanager.storage.models.DateAfterModification;
import com.azure.resourcemanager.storage.models.ManagementPolicyAction;
import com.azure.resourcemanager.storage.models.ManagementPolicyBaseBlob;
import com.azure.resourcemanager.storage.models.ManagementPolicyDefinition;
import com.azure.resourcemanager.storage.models.ManagementPolicyFilter;
import com.azure.resourcemanager.storage.models.ManagementPolicyName;
import com.azure.resourcemanager.storage.models.ManagementPolicyRule;
import com.azure.resourcemanager.storage.models.ManagementPolicySchema;
import com.azure.resourcemanager.storage.models.ManagementPolicySnapShot;
import com.azure.resourcemanager.storage.models.ManagementPolicyVersion;
import com.azure.resourcemanager.storage.models.RuleType;
import java.util.Arrays;
/** Samples for ManagementPolicies CreateOrUpdate. */
public final class Main {
/*
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/
* StorageAccountSetManagementPolicyForBlockAndAppendBlobs.json
*/
/**
* Sample code: StorageAccountSetManagementPolicyForBlockAndAppendBlobs.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
storageAccountSetManagementPolicyForBlockAndAppendBlobs(com.azure.resourcemanager.AzureResourceManager azure) {
azure.storageAccounts().manager().serviceClient().getManagementPolicies()
.createOrUpdateWithResponse("res7687", "sto9699", ManagementPolicyName.DEFAULT,
new ManagementPolicyInner()
.withPolicy(
new ManagementPolicySchema()
.withRules(
Arrays.asList(new ManagementPolicyRule().withEnabled(true).withName("olcmtest1")
.withType(RuleType.LIFECYCLE)
.withDefinition(new ManagementPolicyDefinition()
.withActions(new ManagementPolicyAction()
.withBaseBlob(
new ManagementPolicyBaseBlob().withDelete(new DateAfterModification()
.withDaysAfterModificationGreaterThan(90.0F)))
.withSnapshot(new ManagementPolicySnapShot().withDelete(
new DateAfterCreation().withDaysAfterCreationGreaterThan(90f)))
.withVersion(new ManagementPolicyVersion().withDelete(
new DateAfterCreation().withDaysAfterCreationGreaterThan(90f))))
.withFilters(new ManagementPolicyFilter()
.withPrefixMatch(Arrays.asList("olcmtestcontainer1"))
.withBlobTypes(Arrays.asList("blockBlob", "appendBlob"))))))),
com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.storage import StorageManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-storage
# USAGE
python storage_account_set_management_policy_for_block_and_append_blobs.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = StorageManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.management_policies.create_or_update(
resource_group_name="res7687",
account_name="sto9699",
management_policy_name="default",
properties={
"properties": {
"policy": {
"rules": [
{
"definition": {
"actions": {
"baseBlob": {"delete": {"daysAfterModificationGreaterThan": 90}},
"snapshot": {"delete": {"daysAfterCreationGreaterThan": 90}},
"version": {"delete": {"daysAfterCreationGreaterThan": 90}},
},
"filters": {
"blobTypes": ["blockBlob", "appendBlob"],
"prefixMatch": ["olcmtestcontainer1"],
},
},
"enabled": True,
"name": "olcmtest1",
"type": "Lifecycle",
}
]
}
}
},
)
print(response)
# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicyForBlockAndAppendBlobs.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armstorage_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0baf811c3c76c87b3c127d098519bd97141222dd/specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicyForBlockAndAppendBlobs.json
func ExampleManagementPoliciesClient_CreateOrUpdate_storageAccountSetManagementPolicyForBlockAndAppendBlobs() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armstorage.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewManagementPoliciesClient().CreateOrUpdate(ctx, "res7687", "sto9699", armstorage.ManagementPolicyNameDefault, armstorage.ManagementPolicy{
Properties: &armstorage.ManagementPolicyProperties{
Policy: &armstorage.ManagementPolicySchema{
Rules: []*armstorage.ManagementPolicyRule{
{
Name: to.Ptr("olcmtest1"),
Type: to.Ptr(armstorage.RuleTypeLifecycle),
Definition: &armstorage.ManagementPolicyDefinition{
Actions: &armstorage.ManagementPolicyAction{
BaseBlob: &armstorage.ManagementPolicyBaseBlob{
Delete: &armstorage.DateAfterModification{
DaysAfterModificationGreaterThan: to.Ptr[float32](90),
},
},
Snapshot: &armstorage.ManagementPolicySnapShot{
Delete: &armstorage.DateAfterCreation{
DaysAfterCreationGreaterThan: to.Ptr[float32](90),
},
},
Version: &armstorage.ManagementPolicyVersion{
Delete: &armstorage.DateAfterCreation{
DaysAfterCreationGreaterThan: to.Ptr[float32](90),
},
},
},
Filters: &armstorage.ManagementPolicyFilter{
BlobTypes: []*string{
to.Ptr("blockBlob"),
to.Ptr("appendBlob")},
PrefixMatch: []*string{
to.Ptr("olcmtestcontainer1")},
},
},
Enabled: to.Ptr(true),
}},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.ManagementPolicy = armstorage.ManagementPolicy{
// Name: to.Ptr("DefaultManagementPolicy"),
// Type: to.Ptr("Microsoft.Storage/storageAccounts/managementPolicies"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Storage/storageAccounts/sto288/managementPolicies/default"),
// Properties: &armstorage.ManagementPolicyProperties{
// LastModifiedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-08T02:53:39.093Z"); return t}()),
// Policy: &armstorage.ManagementPolicySchema{
// Rules: []*armstorage.ManagementPolicyRule{
// {
// Name: to.Ptr("olcmtest1"),
// Type: to.Ptr(armstorage.RuleTypeLifecycle),
// Definition: &armstorage.ManagementPolicyDefinition{
// Actions: &armstorage.ManagementPolicyAction{
// BaseBlob: &armstorage.ManagementPolicyBaseBlob{
// Delete: &armstorage.DateAfterModification{
// DaysAfterModificationGreaterThan: to.Ptr[float32](90),
// },
// },
// Snapshot: &armstorage.ManagementPolicySnapShot{
// Delete: &armstorage.DateAfterCreation{
// DaysAfterCreationGreaterThan: to.Ptr[float32](90),
// },
// },
// Version: &armstorage.ManagementPolicyVersion{
// Delete: &armstorage.DateAfterCreation{
// DaysAfterCreationGreaterThan: to.Ptr[float32](90),
// },
// },
// },
// Filters: &armstorage.ManagementPolicyFilter{
// BlobTypes: []*string{
// to.Ptr("blockBlob"),
// to.Ptr("appendBlob")},
// PrefixMatch: []*string{
// to.Ptr("olcmtestcontainer1")},
// },
// },
// Enabled: to.Ptr(true),
// }},
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { StorageManagementClient } = require("@azure/arm-storage");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Sets the managementpolicy to the specified storage account.
*
* @summary Sets the managementpolicy to the specified storage account.
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicyForBlockAndAppendBlobs.json
*/
async function storageAccountSetManagementPolicyForBlockAndAppendBlobs() {
const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687";
const accountName = "sto9699";
const managementPolicyName = "default";
const properties = {
policy: {
rules: [
{
name: "olcmtest1",
type: "Lifecycle",
definition: {
actions: {
baseBlob: { delete: { daysAfterModificationGreaterThan: 90 } },
snapshot: { delete: { daysAfterCreationGreaterThan: 90 } },
version: { delete: { daysAfterCreationGreaterThan: 90 } },
},
filters: {
blobTypes: ["blockBlob", "appendBlob"],
prefixMatch: ["olcmtestcontainer1"],
},
},
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);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Storage/storageAccounts/sto288/managementPolicies/default",
"name": "DefaultManagementPolicy",
"type": "Microsoft.Storage/storageAccounts/managementPolicies",
"properties": {
"policy": {
"rules": [
{
"enabled": true,
"name": "olcmtest1",
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [
"blockBlob",
"appendBlob"
],
"prefixMatch": [
"olcmtestcontainer1"
]
},
"actions": {
"baseBlob": {
"delete": {
"daysAfterModificationGreaterThan": 90
}
},
"snapshot": {
"delete": {
"daysAfterCreationGreaterThan": 90
}
},
"version": {
"delete": {
"daysAfterCreationGreaterThan": 90
}
}
}
}
}
]
},
"lastModifiedTime": "2018-06-08T02:53:39.0932539Z"
}
}
StorageAccountSetManagementPolicyHotTierActions
Sample Request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/res7687/providers/Microsoft.Storage/storageAccounts/sto9699/managementPolicies/default?api-version=2023-01-01
{
"properties": {
"policy": {
"rules": [
{
"enabled": true,
"name": "olcmtest1",
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [
"blockBlob"
],
"prefixMatch": [
"olcmtestcontainer1"
]
},
"actions": {
"baseBlob": {
"tierToHot": {
"daysAfterModificationGreaterThan": 30
}
},
"snapshot": {
"tierToHot": {
"daysAfterCreationGreaterThan": 30
}
},
"version": {
"tierToHot": {
"daysAfterCreationGreaterThan": 30
}
}
}
}
}
]
}
}
}
import com.azure.resourcemanager.storage.fluent.models.ManagementPolicyInner;
import com.azure.resourcemanager.storage.models.DateAfterCreation;
import com.azure.resourcemanager.storage.models.DateAfterModification;
import com.azure.resourcemanager.storage.models.ManagementPolicyAction;
import com.azure.resourcemanager.storage.models.ManagementPolicyBaseBlob;
import com.azure.resourcemanager.storage.models.ManagementPolicyDefinition;
import com.azure.resourcemanager.storage.models.ManagementPolicyFilter;
import com.azure.resourcemanager.storage.models.ManagementPolicyName;
import com.azure.resourcemanager.storage.models.ManagementPolicyRule;
import com.azure.resourcemanager.storage.models.ManagementPolicySchema;
import com.azure.resourcemanager.storage.models.ManagementPolicySnapShot;
import com.azure.resourcemanager.storage.models.ManagementPolicyVersion;
import com.azure.resourcemanager.storage.models.RuleType;
import java.util.Arrays;
/** Samples for ManagementPolicies CreateOrUpdate. */
public final class Main {
/*
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/
* StorageAccountSetManagementPolicyHotTierActions.json
*/
/**
* Sample code: StorageAccountSetManagementPolicyHotTierActions.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
storageAccountSetManagementPolicyHotTierActions(com.azure.resourcemanager.AzureResourceManager azure) {
azure.storageAccounts().manager().serviceClient().getManagementPolicies()
.createOrUpdateWithResponse("res7687", "sto9699", ManagementPolicyName.DEFAULT,
new ManagementPolicyInner()
.withPolicy(
new ManagementPolicySchema()
.withRules(
Arrays.asList(new ManagementPolicyRule().withEnabled(true).withName("olcmtest1")
.withType(RuleType.LIFECYCLE)
.withDefinition(new ManagementPolicyDefinition()
.withActions(new ManagementPolicyAction()
.withBaseBlob(
new ManagementPolicyBaseBlob().withTierToHot(new DateAfterModification()
.withDaysAfterModificationGreaterThan(30.0F)))
.withSnapshot(new ManagementPolicySnapShot().withTierToHot(
new DateAfterCreation().withDaysAfterCreationGreaterThan(30f)))
.withVersion(new ManagementPolicyVersion().withTierToHot(
new DateAfterCreation().withDaysAfterCreationGreaterThan(30f))))
.withFilters(new ManagementPolicyFilter()
.withPrefixMatch(Arrays.asList("olcmtestcontainer1"))
.withBlobTypes(Arrays.asList("blockBlob"))))))),
com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.storage import StorageManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-storage
# USAGE
python storage_account_set_management_policy_hot_tier_actions.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = StorageManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.management_policies.create_or_update(
resource_group_name="res7687",
account_name="sto9699",
management_policy_name="default",
properties={
"properties": {
"policy": {
"rules": [
{
"definition": {
"actions": {
"baseBlob": {"tierToHot": {"daysAfterModificationGreaterThan": 30}},
"snapshot": {"tierToHot": {"daysAfterCreationGreaterThan": 30}},
"version": {"tierToHot": {"daysAfterCreationGreaterThan": 30}},
},
"filters": {"blobTypes": ["blockBlob"], "prefixMatch": ["olcmtestcontainer1"]},
},
"enabled": True,
"name": "olcmtest1",
"type": "Lifecycle",
}
]
}
}
},
)
print(response)
# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicyHotTierActions.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armstorage_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0baf811c3c76c87b3c127d098519bd97141222dd/specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicyHotTierActions.json
func ExampleManagementPoliciesClient_CreateOrUpdate_storageAccountSetManagementPolicyHotTierActions() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armstorage.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewManagementPoliciesClient().CreateOrUpdate(ctx, "res7687", "sto9699", armstorage.ManagementPolicyNameDefault, armstorage.ManagementPolicy{
Properties: &armstorage.ManagementPolicyProperties{
Policy: &armstorage.ManagementPolicySchema{
Rules: []*armstorage.ManagementPolicyRule{
{
Name: to.Ptr("olcmtest1"),
Type: to.Ptr(armstorage.RuleTypeLifecycle),
Definition: &armstorage.ManagementPolicyDefinition{
Actions: &armstorage.ManagementPolicyAction{
BaseBlob: &armstorage.ManagementPolicyBaseBlob{
TierToHot: &armstorage.DateAfterModification{
DaysAfterModificationGreaterThan: to.Ptr[float32](30),
},
},
Snapshot: &armstorage.ManagementPolicySnapShot{
TierToHot: &armstorage.DateAfterCreation{
DaysAfterCreationGreaterThan: to.Ptr[float32](30),
},
},
Version: &armstorage.ManagementPolicyVersion{
TierToHot: &armstorage.DateAfterCreation{
DaysAfterCreationGreaterThan: to.Ptr[float32](30),
},
},
},
Filters: &armstorage.ManagementPolicyFilter{
BlobTypes: []*string{
to.Ptr("blockBlob")},
PrefixMatch: []*string{
to.Ptr("olcmtestcontainer1")},
},
},
Enabled: to.Ptr(true),
}},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.ManagementPolicy = armstorage.ManagementPolicy{
// Name: to.Ptr("DefaultManagementPolicy"),
// Type: to.Ptr("Microsoft.Storage/storageAccounts/managementPolicies"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Storage/storageAccounts/sto288/managementPolicies/default"),
// Properties: &armstorage.ManagementPolicyProperties{
// LastModifiedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-08T02:53:39.093Z"); return t}()),
// Policy: &armstorage.ManagementPolicySchema{
// Rules: []*armstorage.ManagementPolicyRule{
// {
// Name: to.Ptr("olcmtest1"),
// Type: to.Ptr(armstorage.RuleTypeLifecycle),
// Definition: &armstorage.ManagementPolicyDefinition{
// Actions: &armstorage.ManagementPolicyAction{
// BaseBlob: &armstorage.ManagementPolicyBaseBlob{
// TierToHot: &armstorage.DateAfterModification{
// DaysAfterModificationGreaterThan: to.Ptr[float32](30),
// },
// },
// Snapshot: &armstorage.ManagementPolicySnapShot{
// TierToHot: &armstorage.DateAfterCreation{
// DaysAfterCreationGreaterThan: to.Ptr[float32](30),
// },
// },
// Version: &armstorage.ManagementPolicyVersion{
// TierToHot: &armstorage.DateAfterCreation{
// DaysAfterCreationGreaterThan: to.Ptr[float32](30),
// },
// },
// },
// Filters: &armstorage.ManagementPolicyFilter{
// BlobTypes: []*string{
// to.Ptr("blockBlob")},
// PrefixMatch: []*string{
// to.Ptr("olcmtestcontainer1")},
// },
// },
// Enabled: to.Ptr(true),
// }},
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { StorageManagementClient } = require("@azure/arm-storage");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Sets the managementpolicy to the specified storage account.
*
* @summary Sets the managementpolicy to the specified storage account.
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicyHotTierActions.json
*/
async function storageAccountSetManagementPolicyHotTierActions() {
const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687";
const accountName = "sto9699";
const managementPolicyName = "default";
const properties = {
policy: {
rules: [
{
name: "olcmtest1",
type: "Lifecycle",
definition: {
actions: {
baseBlob: { tierToHot: { daysAfterModificationGreaterThan: 30 } },
snapshot: { tierToHot: { daysAfterCreationGreaterThan: 30 } },
version: { tierToHot: { daysAfterCreationGreaterThan: 30 } },
},
filters: {
blobTypes: ["blockBlob"],
prefixMatch: ["olcmtestcontainer1"],
},
},
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);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Storage/storageAccounts/sto288/managementPolicies/default",
"name": "DefaultManagementPolicy",
"type": "Microsoft.Storage/storageAccounts/managementPolicies",
"properties": {
"policy": {
"rules": [
{
"enabled": true,
"name": "olcmtest1",
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [
"blockBlob"
],
"prefixMatch": [
"olcmtestcontainer1"
]
},
"actions": {
"baseBlob": {
"tierToHot": {
"daysAfterModificationGreaterThan": 30
}
},
"snapshot": {
"tierToHot": {
"daysAfterCreationGreaterThan": 30
}
},
"version": {
"tierToHot": {
"daysAfterCreationGreaterThan": 30
}
}
}
}
}
]
},
"lastModifiedTime": "2021-06-08T02:53:39.0932539Z"
}
}
StorageAccountSetManagementPolicyWithSnapshotAndVersion
Sample Request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/res7687/providers/Microsoft.Storage/storageAccounts/sto9699/managementPolicies/default?api-version=2023-01-01
{
"properties": {
"policy": {
"rules": [
{
"enabled": true,
"name": "olcmtest1",
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [
"blockBlob"
],
"prefixMatch": [
"olcmtestcontainer1"
]
},
"actions": {
"baseBlob": {
"tierToCool": {
"daysAfterModificationGreaterThan": 30
},
"tierToArchive": {
"daysAfterModificationGreaterThan": 90
},
"delete": {
"daysAfterModificationGreaterThan": 1000
}
},
"snapshot": {
"tierToCool": {
"daysAfterCreationGreaterThan": 30
},
"tierToArchive": {
"daysAfterCreationGreaterThan": 90
},
"delete": {
"daysAfterCreationGreaterThan": 1000
}
},
"version": {
"tierToCool": {
"daysAfterCreationGreaterThan": 30
},
"tierToArchive": {
"daysAfterCreationGreaterThan": 90
},
"delete": {
"daysAfterCreationGreaterThan": 1000
}
}
}
}
}
]
}
}
}
import com.azure.resourcemanager.storage.fluent.models.ManagementPolicyInner;
import com.azure.resourcemanager.storage.models.DateAfterCreation;
import com.azure.resourcemanager.storage.models.DateAfterModification;
import com.azure.resourcemanager.storage.models.ManagementPolicyAction;
import com.azure.resourcemanager.storage.models.ManagementPolicyBaseBlob;
import com.azure.resourcemanager.storage.models.ManagementPolicyDefinition;
import com.azure.resourcemanager.storage.models.ManagementPolicyFilter;
import com.azure.resourcemanager.storage.models.ManagementPolicyName;
import com.azure.resourcemanager.storage.models.ManagementPolicyRule;
import com.azure.resourcemanager.storage.models.ManagementPolicySchema;
import com.azure.resourcemanager.storage.models.ManagementPolicySnapShot;
import com.azure.resourcemanager.storage.models.ManagementPolicyVersion;
import com.azure.resourcemanager.storage.models.RuleType;
import java.util.Arrays;
/** Samples for ManagementPolicies CreateOrUpdate. */
public final class Main {
/*
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/
* StorageAccountSetManagementPolicyWithSnapshotAndVersion.json
*/
/**
* Sample code: StorageAccountSetManagementPolicyWithSnapshotAndVersion.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
storageAccountSetManagementPolicyWithSnapshotAndVersion(com.azure.resourcemanager.AzureResourceManager azure) {
azure.storageAccounts().manager().serviceClient().getManagementPolicies()
.createOrUpdateWithResponse("res7687", "sto9699", ManagementPolicyName.DEFAULT,
new ManagementPolicyInner()
.withPolicy(
new ManagementPolicySchema()
.withRules(
Arrays.asList(new ManagementPolicyRule().withEnabled(true).withName("olcmtest1")
.withType(RuleType.LIFECYCLE)
.withDefinition(new ManagementPolicyDefinition()
.withActions(new ManagementPolicyAction()
.withBaseBlob(new ManagementPolicyBaseBlob()
.withTierToCool(new DateAfterModification()
.withDaysAfterModificationGreaterThan(30.0F))
.withTierToArchive(new DateAfterModification()
.withDaysAfterModificationGreaterThan(90.0F))
.withDelete(new DateAfterModification()
.withDaysAfterModificationGreaterThan(1000.0F)))
.withSnapshot(new ManagementPolicySnapShot()
.withTierToCool(
new DateAfterCreation().withDaysAfterCreationGreaterThan(30f))
.withTierToArchive(
new DateAfterCreation().withDaysAfterCreationGreaterThan(90f))
.withDelete(
new DateAfterCreation().withDaysAfterCreationGreaterThan(1000f)))
.withVersion(new ManagementPolicyVersion()
.withTierToCool(
new DateAfterCreation().withDaysAfterCreationGreaterThan(30f))
.withTierToArchive(
new DateAfterCreation().withDaysAfterCreationGreaterThan(90f))
.withDelete(
new DateAfterCreation().withDaysAfterCreationGreaterThan(1000f))))
.withFilters(new ManagementPolicyFilter()
.withPrefixMatch(Arrays.asList("olcmtestcontainer1"))
.withBlobTypes(Arrays.asList("blockBlob"))))))),
com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.storage import StorageManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-storage
# USAGE
python storage_account_set_management_policy_with_snapshot_and_version.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = StorageManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.management_policies.create_or_update(
resource_group_name="res7687",
account_name="sto9699",
management_policy_name="default",
properties={
"properties": {
"policy": {
"rules": [
{
"definition": {
"actions": {
"baseBlob": {
"delete": {"daysAfterModificationGreaterThan": 1000},
"tierToArchive": {"daysAfterModificationGreaterThan": 90},
"tierToCool": {"daysAfterModificationGreaterThan": 30},
},
"snapshot": {
"delete": {"daysAfterCreationGreaterThan": 1000},
"tierToArchive": {"daysAfterCreationGreaterThan": 90},
"tierToCool": {"daysAfterCreationGreaterThan": 30},
},
"version": {
"delete": {"daysAfterCreationGreaterThan": 1000},
"tierToArchive": {"daysAfterCreationGreaterThan": 90},
"tierToCool": {"daysAfterCreationGreaterThan": 30},
},
},
"filters": {"blobTypes": ["blockBlob"], "prefixMatch": ["olcmtestcontainer1"]},
},
"enabled": True,
"name": "olcmtest1",
"type": "Lifecycle",
}
]
}
}
},
)
print(response)
# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicyWithSnapshotAndVersion.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armstorage_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0baf811c3c76c87b3c127d098519bd97141222dd/specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicyWithSnapshotAndVersion.json
func ExampleManagementPoliciesClient_CreateOrUpdate_storageAccountSetManagementPolicyWithSnapshotAndVersion() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armstorage.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewManagementPoliciesClient().CreateOrUpdate(ctx, "res7687", "sto9699", armstorage.ManagementPolicyNameDefault, armstorage.ManagementPolicy{
Properties: &armstorage.ManagementPolicyProperties{
Policy: &armstorage.ManagementPolicySchema{
Rules: []*armstorage.ManagementPolicyRule{
{
Name: to.Ptr("olcmtest1"),
Type: to.Ptr(armstorage.RuleTypeLifecycle),
Definition: &armstorage.ManagementPolicyDefinition{
Actions: &armstorage.ManagementPolicyAction{
BaseBlob: &armstorage.ManagementPolicyBaseBlob{
Delete: &armstorage.DateAfterModification{
DaysAfterModificationGreaterThan: to.Ptr[float32](1000),
},
TierToArchive: &armstorage.DateAfterModification{
DaysAfterModificationGreaterThan: to.Ptr[float32](90),
},
TierToCool: &armstorage.DateAfterModification{
DaysAfterModificationGreaterThan: to.Ptr[float32](30),
},
},
Snapshot: &armstorage.ManagementPolicySnapShot{
Delete: &armstorage.DateAfterCreation{
DaysAfterCreationGreaterThan: to.Ptr[float32](1000),
},
TierToArchive: &armstorage.DateAfterCreation{
DaysAfterCreationGreaterThan: to.Ptr[float32](90),
},
TierToCool: &armstorage.DateAfterCreation{
DaysAfterCreationGreaterThan: to.Ptr[float32](30),
},
},
Version: &armstorage.ManagementPolicyVersion{
Delete: &armstorage.DateAfterCreation{
DaysAfterCreationGreaterThan: to.Ptr[float32](1000),
},
TierToArchive: &armstorage.DateAfterCreation{
DaysAfterCreationGreaterThan: to.Ptr[float32](90),
},
TierToCool: &armstorage.DateAfterCreation{
DaysAfterCreationGreaterThan: to.Ptr[float32](30),
},
},
},
Filters: &armstorage.ManagementPolicyFilter{
BlobTypes: []*string{
to.Ptr("blockBlob")},
PrefixMatch: []*string{
to.Ptr("olcmtestcontainer1")},
},
},
Enabled: to.Ptr(true),
}},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.ManagementPolicy = armstorage.ManagementPolicy{
// Name: to.Ptr("DefaultManagementPolicy"),
// Type: to.Ptr("Microsoft.Storage/storageAccounts/managementPolicies"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Storage/storageAccounts/sto288/managementPolicies/default"),
// Properties: &armstorage.ManagementPolicyProperties{
// LastModifiedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-06-08T02:53:39.093Z"); return t}()),
// Policy: &armstorage.ManagementPolicySchema{
// Rules: []*armstorage.ManagementPolicyRule{
// {
// Name: to.Ptr("olcmtest1"),
// Type: to.Ptr(armstorage.RuleTypeLifecycle),
// Definition: &armstorage.ManagementPolicyDefinition{
// Actions: &armstorage.ManagementPolicyAction{
// BaseBlob: &armstorage.ManagementPolicyBaseBlob{
// Delete: &armstorage.DateAfterModification{
// DaysAfterModificationGreaterThan: to.Ptr[float32](1000),
// },
// TierToArchive: &armstorage.DateAfterModification{
// DaysAfterModificationGreaterThan: to.Ptr[float32](90),
// },
// TierToCool: &armstorage.DateAfterModification{
// DaysAfterModificationGreaterThan: to.Ptr[float32](30),
// },
// },
// Snapshot: &armstorage.ManagementPolicySnapShot{
// Delete: &armstorage.DateAfterCreation{
// DaysAfterCreationGreaterThan: to.Ptr[float32](1000),
// },
// TierToArchive: &armstorage.DateAfterCreation{
// DaysAfterCreationGreaterThan: to.Ptr[float32](90),
// },
// TierToCool: &armstorage.DateAfterCreation{
// DaysAfterCreationGreaterThan: to.Ptr[float32](30),
// },
// },
// Version: &armstorage.ManagementPolicyVersion{
// Delete: &armstorage.DateAfterCreation{
// DaysAfterCreationGreaterThan: to.Ptr[float32](1000),
// },
// TierToArchive: &armstorage.DateAfterCreation{
// DaysAfterCreationGreaterThan: to.Ptr[float32](90),
// },
// TierToCool: &armstorage.DateAfterCreation{
// DaysAfterCreationGreaterThan: to.Ptr[float32](30),
// },
// },
// },
// Filters: &armstorage.ManagementPolicyFilter{
// BlobTypes: []*string{
// to.Ptr("blockBlob")},
// PrefixMatch: []*string{
// to.Ptr("olcmtestcontainer1")},
// },
// },
// Enabled: to.Ptr(true),
// }},
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { StorageManagementClient } = require("@azure/arm-storage");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Sets the managementpolicy to the specified storage account.
*
* @summary Sets the managementpolicy to the specified storage account.
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/StorageAccountSetManagementPolicyWithSnapshotAndVersion.json
*/
async function storageAccountSetManagementPolicyWithSnapshotAndVersion() {
const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "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: 1000 },
tierToArchive: { daysAfterCreationGreaterThan: 90 },
tierToCool: { daysAfterCreationGreaterThan: 30 },
},
version: {
delete: { daysAfterCreationGreaterThan: 1000 },
tierToArchive: { daysAfterCreationGreaterThan: 90 },
tierToCool: { daysAfterCreationGreaterThan: 30 },
},
},
filters: {
blobTypes: ["blockBlob"],
prefixMatch: ["olcmtestcontainer1"],
},
},
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);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample Response
{
"id": "/subscriptions/{subscription-id}/resourceGroups/res7231/providers/Microsoft.Storage/storageAccounts/sto288/managementPolicies/default",
"name": "DefaultManagementPolicy",
"type": "Microsoft.Storage/storageAccounts/managementPolicies",
"properties": {
"policy": {
"rules": [
{
"enabled": true,
"name": "olcmtest1",
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [
"blockBlob"
],
"prefixMatch": [
"olcmtestcontainer1"
]
},
"actions": {
"baseBlob": {
"tierToCool": {
"daysAfterModificationGreaterThan": 30
},
"tierToArchive": {
"daysAfterModificationGreaterThan": 90
},
"delete": {
"daysAfterModificationGreaterThan": 1000
}
},
"snapshot": {
"tierToCool": {
"daysAfterCreationGreaterThan": 30
},
"tierToArchive": {
"daysAfterCreationGreaterThan": 90
},
"delete": {
"daysAfterCreationGreaterThan": 1000
}
},
"version": {
"tierToCool": {
"daysAfterCreationGreaterThan": 30
},
"tierToArchive": {
"daysAfterCreationGreaterThan": 90
},
"delete": {
"daysAfterCreationGreaterThan": 1000
}
}
}
}
}
]
},
"lastModifiedTime": "2018-06-08T02:53:39.0932539Z"
}
}
Definitions
DateAfterCreation
Object to define snapshot and version action conditions.
Name |
Type |
Description |
daysAfterCreationGreaterThan
|
number
|
Value indicating the age in days after creation
|
daysAfterLastTierChangeGreaterThan
|
number
|
Value indicating the age in days after last blob tier change time. This property is only applicable for tierToArchive actions and requires daysAfterCreationGreaterThan to be set for snapshots and blob version based actions. The blob will be archived if both the conditions are satisfied.
|
DateAfterModification
Object to define the base blob action conditions. Properties daysAfterModificationGreaterThan, daysAfterLastAccessTimeGreaterThan and daysAfterCreationGreaterThan are mutually exclusive. The daysAfterLastTierChangeGreaterThan property is only applicable for tierToArchive actions which requires daysAfterModificationGreaterThan to be set, also it cannot be used in conjunction with daysAfterLastAccessTimeGreaterThan or daysAfterCreationGreaterThan.
Name |
Type |
Description |
daysAfterCreationGreaterThan
|
number
|
Value indicating the age in days after blob creation.
|
daysAfterLastAccessTimeGreaterThan
|
number
|
Value indicating the age in days after last blob access. This property can only be used in conjunction with last access time tracking policy
|
daysAfterLastTierChangeGreaterThan
|
number
|
Value indicating the age in days after last blob tier change time. This property is only applicable for tierToArchive actions and requires daysAfterModificationGreaterThan to be set for baseBlobs based actions. The blob will be archived if both the conditions are satisfied.
|
daysAfterModificationGreaterThan
|
number
|
Value indicating the age in days after last modification
|
ManagementPolicy
The Get Storage Account ManagementPolicies operation response.
Name |
Type |
Description |
id
|
string
|
Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
name
|
string
|
The name of the resource
|
properties.lastModifiedTime
|
string
|
Returns the date and time the ManagementPolicies was last modified.
|
properties.policy
|
ManagementPolicySchema
|
The Storage Account ManagementPolicy, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts.
|
type
|
string
|
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
|
ManagementPolicyAction
Actions are applied to the filtered blobs when the execution condition is met.
ManagementPolicyBaseBlob
Management policy action for base blob.
Name |
Type |
Description |
delete
|
DateAfterModification
|
The function to delete the blob
|
enableAutoTierToHotFromCool
|
boolean
|
This property enables auto tiering of a blob from cool to hot on a blob access. This property requires tierToCool.daysAfterLastAccessTimeGreaterThan.
|
tierToArchive
|
DateAfterModification
|
The function to tier blobs to archive storage.
|
tierToCold
|
DateAfterModification
|
The function to tier blobs to cold storage.
|
tierToCool
|
DateAfterModification
|
The function to tier blobs to cool storage.
|
tierToHot
|
DateAfterModification
|
The function to tier blobs to hot storage. This action can only be used with Premium Block Blob Storage Accounts
|
ManagementPolicyDefinition
An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set.
ManagementPolicyFilter
Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters.
Name |
Type |
Description |
blobIndexMatch
|
TagFilter[]
|
An array of blob index tag based filters, there can be at most 10 tag filters
|
blobTypes
|
string[]
|
An array of predefined enum values. Currently blockBlob supports all tiering and delete actions. Only delete actions are supported for appendBlob.
|
prefixMatch
|
string[]
|
An array of strings for prefixes to be match.
|
ManagementPolicyName
The name of the Storage Account Management Policy. It should always be 'default'
Name |
Type |
Description |
default
|
string
|
|
ManagementPolicyRule
An object that wraps the Lifecycle rule. Each rule is uniquely defined by name.
Name |
Type |
Description |
definition
|
ManagementPolicyDefinition
|
An object that defines the Lifecycle rule.
|
enabled
|
boolean
|
Rule is enabled if set to true.
|
name
|
string
|
A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy.
|
type
|
RuleType
|
The valid value is Lifecycle
|
ManagementPolicySchema
The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts.
ManagementPolicySnapShot
Management policy action for snapshot.
Name |
Type |
Description |
delete
|
DateAfterCreation
|
The function to delete the blob snapshot
|
tierToArchive
|
DateAfterCreation
|
The function to tier blob snapshot to archive storage.
|
tierToCold
|
DateAfterCreation
|
The function to tier blobs to cold storage.
|
tierToCool
|
DateAfterCreation
|
The function to tier blob snapshot to cool storage.
|
tierToHot
|
DateAfterCreation
|
The function to tier blobs to hot storage. This action can only be used with Premium Block Blob Storage Accounts
|
ManagementPolicyVersion
Management policy action for blob version.
Name |
Type |
Description |
delete
|
DateAfterCreation
|
The function to delete the blob version
|
tierToArchive
|
DateAfterCreation
|
The function to tier blob version to archive storage.
|
tierToCold
|
DateAfterCreation
|
The function to tier blobs to cold storage.
|
tierToCool
|
DateAfterCreation
|
The function to tier blob version to cool storage.
|
tierToHot
|
DateAfterCreation
|
The function to tier blobs to hot storage. This action can only be used with Premium Block Blob Storage Accounts
|
RuleType
The valid value is Lifecycle
Name |
Type |
Description |
Lifecycle
|
string
|
|
TagFilter
Blob index tag based filtering for blob objects
Name |
Type |
Description |
name
|
string
|
This is the filter tag name, it can have 1 - 128 characters
|
op
|
string
|
This is the comparison operator which is used for object comparison and filtering. Only == (equality operator) is currently supported
|
value
|
string
|
This is the filter tag value field used for tag based filtering, it can have 0 - 256 characters
|