Définit la stratégie de gestion sur le compte de stockage spécifié.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/default?api-version=2023-01-01
Paramètres URI
Nom |
Dans |
Obligatoire |
Type |
Description |
accountName
|
path |
True
|
string
|
Nom du compte de stockage au sein du groupe de ressources spécifié. Ce nom doit comprendre entre 3 et 24 caractères, uniquement des lettres en minuscules et des nombres.
Regex pattern: ^[a-z0-9]+$
|
managementPolicyName
|
path |
True
|
ManagementPolicyName
|
Nom de la stratégie de gestion des comptes de stockage. Il doit toujours être « par défaut »
|
resourceGroupName
|
path |
True
|
string
|
Nom du groupe de ressources dans l’abonnement de l’utilisateur. Le nom ne respecte pas la casse.
Regex pattern: ^[-\w\._\(\)]+$
|
subscriptionId
|
path |
True
|
string
|
ID de l’abonnement cible.
|
api-version
|
query |
True
|
string
|
Version de l’API à utiliser pour cette opération.
|
Corps de la demande
Réponses
Nom |
Type |
Description |
200 OK
|
ManagementPolicy
|
OK : placez correctement la stratégie de gestion.
|
Sécurité
azure_auth
Flux OAuth2 Azure Active Directory
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Nom |
Description |
user_impersonation
|
Emprunter l’identité de votre compte d’utilisateur
|
Exemples
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"
}
}
Définitions
Nom |
Description |
DateAfterCreation
|
Objet pour définir les conditions d’action de instantané et de version.
|
DateAfterModification
|
Objet pour définir les conditions d’action d’objet blob de base. Les propriétés daysAfterModificationGreaterThan, daysAfterLastAccessTimeGreaterThan et daysAfterCreationGreaterThan s’excluent mutuellement. La propriété daysAfterLastTierChangeGreaterThan s’applique uniquement aux actions tierToArchive qui nécessitent la définition de daysAfterModificationGreaterThan. Elle ne peut pas non plus être utilisée conjointement avec daysAfterLastAccessTimeGreaterThan ou daysAfterCreationGreaterThan.
|
ManagementPolicy
|
Réponse de l’opération Get Storage Account ManagementPolicies.
|
ManagementPolicyAction
|
Des actions sont appliquées aux objets blob filtrés lorsque la condition d’exécution est remplie.
|
ManagementPolicyBaseBlob
|
Action de stratégie de gestion pour l’objet blob de base.
|
ManagementPolicyDefinition
|
Objet qui définit la règle de cycle de vie. Chaque définition se compose d’un jeu de filtres et d’un jeu d’actions.
|
ManagementPolicyFilter
|
Les filtres limitent les actions des règles à un sous-ensemble d’objets blob dans le compte de stockage. Si plusieurs filtres sont définis, un AND logique est effectué sur tous les filtres.
|
ManagementPolicyName
|
Nom de la stratégie de gestion des comptes de stockage. Il doit toujours être « par défaut »
|
ManagementPolicyRule
|
Objet qui encapsule la règle de cycle de vie. Chaque règle est définie de manière unique par nom.
|
ManagementPolicySchema
|
Règles de gestion des comptes de stockageStratégies. Pour plus d’informations, consultez : https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts.
|
ManagementPolicySnapShot
|
Action de stratégie de gestion pour instantané.
|
ManagementPolicyVersion
|
Action de stratégie de gestion pour la version d’objet blob.
|
RuleType
|
La valeur valide est Cycle de vie
|
TagFilter
|
Filtrage basé sur les étiquettes d’index d’objets blob pour les objets blob
|
DateAfterCreation
Objet pour définir les conditions d’action de instantané et de version.
Nom |
Type |
Description |
daysAfterCreationGreaterThan
|
number
|
Valeur indiquant l’âge en jours après la création
|
daysAfterLastTierChangeGreaterThan
|
number
|
Valeur indiquant l’âge en jours après l’heure de modification du dernier niveau d’objet blob. Cette propriété s’applique uniquement aux actions tierToArchive et nécessite la définition de daysAfterCreationGreaterThan pour les instantanés et les actions basées sur la version d’objets blob. L’objet blob sera archivé si les deux conditions sont remplies.
|
DateAfterModification
Objet pour définir les conditions d’action d’objet blob de base. Les propriétés daysAfterModificationGreaterThan, daysAfterLastAccessTimeGreaterThan et daysAfterCreationGreaterThan s’excluent mutuellement. La propriété daysAfterLastTierChangeGreaterThan s’applique uniquement aux actions tierToArchive qui nécessitent la définition de daysAfterModificationGreaterThan. Elle ne peut pas non plus être utilisée conjointement avec daysAfterLastAccessTimeGreaterThan ou daysAfterCreationGreaterThan.
Nom |
Type |
Description |
daysAfterCreationGreaterThan
|
number
|
Valeur indiquant l’âge en jours après la création de l’objet blob.
|
daysAfterLastAccessTimeGreaterThan
|
number
|
Valeur indiquant l’âge en jours après le dernier accès aux objets blob. Cette propriété peut uniquement être utilisée conjointement avec la stratégie de suivi du dernier temps d’accès
|
daysAfterLastTierChangeGreaterThan
|
number
|
Valeur indiquant l’âge en jours après l’heure de modification du dernier niveau d’objet blob. Cette propriété s’applique uniquement aux actions tierToArchive et nécessite la définition de daysAfterModificationGreaterThan pour les actions basées sur baseBlobs. L’objet blob sera archivé si les deux conditions sont remplies.
|
daysAfterModificationGreaterThan
|
number
|
Valeur indiquant l’âge en jours après la dernière modification
|
ManagementPolicy
Réponse de l’opération Get Storage Account ManagementPolicies.
Nom |
Type |
Description |
id
|
string
|
ID de ressource complet pour la ressource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
name
|
string
|
nom de la ressource.
|
properties.lastModifiedTime
|
string
|
Retourne la date et l’heure de la dernière modification de ManagementPolicies.
|
properties.policy
|
ManagementPolicySchema
|
Gestion des comptes de stockagePolicy, au format JSON. Pour plus d’informations, consultez : https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts.
|
type
|
string
|
Type de la ressource. Par exemple, « Microsoft.Compute/virtualMachines » ou « Microsoft.Storage/storageAccounts »
|
ManagementPolicyAction
Des actions sont appliquées aux objets blob filtrés lorsque la condition d’exécution est remplie.
ManagementPolicyBaseBlob
Action de stratégie de gestion pour l’objet blob de base.
Nom |
Type |
Description |
delete
|
DateAfterModification
|
Fonction permettant de supprimer l’objet blob
|
enableAutoTierToHotFromCool
|
boolean
|
Cette propriété permet la hiérarchisation automatique d’un objet blob de froid à chaud sur un accès blob. Cette propriété nécessite tierToCool.daysAfterLastAccessTimeGreaterThan.
|
tierToArchive
|
DateAfterModification
|
Fonction de hiérarchisation des objets blob pour archiver le stockage.
|
tierToCold
|
DateAfterModification
|
Fonction de hiérarchisation des objets blob dans le stockage à froid.
|
tierToCool
|
DateAfterModification
|
Fonction à hiérarchiser les objets blob pour refroidir le stockage.
|
tierToHot
|
DateAfterModification
|
Fonction à hiérarchisation des objets blob sur le stockage à chaud. Cette action ne peut être utilisée qu’avec les comptes de stockage d’objets blob de blocs Premium
|
ManagementPolicyDefinition
Objet qui définit la règle de cycle de vie. Chaque définition se compose d’un jeu de filtres et d’un jeu d’actions.
ManagementPolicyFilter
Les filtres limitent les actions des règles à un sous-ensemble d’objets blob dans le compte de stockage. Si plusieurs filtres sont définis, un AND logique est effectué sur tous les filtres.
Nom |
Type |
Description |
blobIndexMatch
|
TagFilter[]
|
Tableau de filtres basés sur des balises d’index d’objet blob, il peut y avoir au maximum 10 filtres de balise
|
blobTypes
|
string[]
|
Un ensemble de valeurs enum prédéfinies. Actuellement, blockBlob prend en charge toutes les actions de hiérarchisation et de suppression. Seules les actions de suppression sont prises en charge pour appendBlob.
|
prefixMatch
|
string[]
|
Un ensemble de chaînes servant à faire correspondre les préfixes.
|
ManagementPolicyName
Nom de la stratégie de gestion des comptes de stockage. Il doit toujours être « par défaut »
Nom |
Type |
Description |
default
|
string
|
|
ManagementPolicyRule
Objet qui encapsule la règle de cycle de vie. Chaque règle est définie de manière unique par nom.
Nom |
Type |
Description |
definition
|
ManagementPolicyDefinition
|
Objet qui définit la règle de cycle de vie.
|
enabled
|
boolean
|
La règle est activée si la valeur est true.
|
name
|
string
|
Un nom de règle peut contenir n’importe quelle combinaison de caractères alphanumériques. Les noms de règle respectent la casse. Ils doivent être uniques dans la stratégie.
|
type
|
RuleType
|
La valeur valide est Cycle de vie
|
ManagementPolicySchema
Règles de gestion des comptes de stockageStratégies. Pour plus d’informations, consultez : https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts.
ManagementPolicySnapShot
Action de stratégie de gestion pour instantané.
Nom |
Type |
Description |
delete
|
DateAfterCreation
|
Fonction permettant de supprimer le instantané d’objet blob
|
tierToArchive
|
DateAfterCreation
|
La fonction à hiérarchisation de l’objet blob instantané pour archiver le stockage.
|
tierToCold
|
DateAfterCreation
|
Fonction de hiérarchisation des objets blob dans le stockage à froid.
|
tierToCool
|
DateAfterCreation
|
La fonction à hiérarchiser l’objet blob instantané au stockage froid.
|
tierToHot
|
DateAfterCreation
|
Fonction à hiérarchisation des objets blob sur le stockage à chaud. Cette action ne peut être utilisée qu’avec les comptes de stockage d’objets blob de blocs Premium
|
ManagementPolicyVersion
Action de stratégie de gestion pour la version d’objet blob.
Nom |
Type |
Description |
delete
|
DateAfterCreation
|
Fonction permettant de supprimer la version de l’objet blob
|
tierToArchive
|
DateAfterCreation
|
Fonction de hiérarchisation de la version d’objet blob pour archiver le stockage.
|
tierToCold
|
DateAfterCreation
|
Fonction de hiérarchisation des objets blob dans le stockage à froid.
|
tierToCool
|
DateAfterCreation
|
Fonction à hiérarchiser la version d’objet blob au stockage froid.
|
tierToHot
|
DateAfterCreation
|
Fonction à hiérarchisation des objets blob sur le stockage à chaud. Cette action ne peut être utilisée qu’avec les comptes de stockage d’objets blob de blocs Premium
|
RuleType
La valeur valide est Cycle de vie
Nom |
Type |
Description |
Lifecycle
|
string
|
|
TagFilter
Filtrage basé sur les étiquettes d’index d’objets blob pour les objets blob
Nom |
Type |
Description |
name
|
string
|
Il s’agit du nom de la balise de filtre, il peut avoir entre 1 et 128 caractères
|
op
|
string
|
Il s’agit de l’opérateur de comparaison utilisé pour la comparaison et le filtrage d’objets. Seul == (opérateur d’égalité) est actuellement pris en charge
|
value
|
string
|
Il s’agit du champ de valeur de balise de filtre utilisé pour le filtrage basé sur les étiquettes, il peut contenir de 0 à 256 caractères
|