Legt die Verwaltungsrichtlinie auf das angegebene Speicherkonto fest.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/default?api-version=2023-01-01
URI-Parameter
Name |
In |
Erforderlich |
Typ |
Beschreibung |
accountName
|
path |
True
|
string
|
Der Name des Speicherkontos innerhalb der angegebenen Ressourcengruppe. Speicherkontonamen müssen zwischen 3 und 24 Zeichen lang sein und dürfen nur Zahlen und Kleinbuchstaben enthalten.
Regex pattern: ^[a-z0-9]+$
|
managementPolicyName
|
path |
True
|
ManagementPolicyName
|
Der Name der Speicherkontoverwaltungsrichtlinie. Es sollte immer "Standard" sein.
|
resourceGroupName
|
path |
True
|
string
|
Der Name der Ressourcengruppe im Abonnement des Benutzers. Für den Namen wird die Groß-/Kleinschreibung nicht beachtet.
Regex pattern: ^[-\w\._\(\)]+$
|
subscriptionId
|
path |
True
|
string
|
Hierbei handelt es sich um die ID des Zielabonnements.
|
api-version
|
query |
True
|
string
|
Hierbei handelt es sich um die für diesen Vorgang zu verwendende API-Version.
|
Anforderungstext
Antworten
Name |
Typ |
Beschreibung |
200 OK
|
ManagementPolicy
|
OK : Die Verwaltungsrichtlinie erfolgreich platzieren.
|
Sicherheit
azure_auth
Azure Active Directory-OAuth2-Flow
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name |
Beschreibung |
user_impersonation
|
Identitätswechsel Ihres Benutzerkontos
|
Beispiele
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"
}
}
Definitionen
Name |
Beschreibung |
DateAfterCreation
|
Objekt, um Momentaufnahme- und Versionsaktionsbedingungen zu definieren.
|
DateAfterModification
|
Objekt zum Definieren der Basisblobaktionsbedingungen. Die Eigenschaften daysAfterModificationGreaterThan, daysAfterLastAccessTimeGreaterThan und daysAfterCreationGreaterThan schließen sich gegenseitig aus. Die daysAfterLastTierChangeGreaterThan-Eigenschaft gilt nur für tierToArchive-Aktionen, für die daysAfterModificationGreaterThan festgelegt werden muss. Außerdem kann sie nicht in Verbindung mit daysAfterLastAccessTimeGreaterThan oder daysAfterCreationGreaterThan verwendet werden.
|
ManagementPolicy
|
Die Antwort des Vorgangs "Storage Account ManagementPolicies abrufen".
|
ManagementPolicyAction
|
Aktionen werden auf die gefilterten Blobs angewendet, wenn die Ausführungsbedingung erfüllt ist.
|
ManagementPolicyBaseBlob
|
Verwaltungsrichtlinienaktion für Basisblob.
|
ManagementPolicyDefinition
|
Ein Objekt, das die Lebenszyklusregel definiert. Jede Definition beinhaltet einen Filtersatz und einen Aktionssatz.
|
ManagementPolicyFilter
|
Filter schränken Regelaktionen auf eine Teilmenge der Blobs innerhalb des Speicherkontos ein. Wenn mehrere Filter definiert sind, wird für alle Filter ein logisches AND ausgeführt.
|
ManagementPolicyName
|
Der Name der Speicherkontoverwaltungsrichtlinie. Es sollte immer "Standard" sein.
|
ManagementPolicyRule
|
Ein Objekt, das die Lebenszyklusregel umschließt. Jede Regel ist eindeutig durch den Namen definiert.
|
ManagementPolicySchema
|
Die SpeicherkontoverwaltungRichtlinienregeln. Weitere Informationen finden Sie unter : https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts.
|
ManagementPolicySnapShot
|
Verwaltungsrichtlinienaktion für Momentaufnahme.
|
ManagementPolicyVersion
|
Verwaltungsrichtlinienaktion für Blobversion.
|
RuleType
|
Der gültige Wert ist Lifecycle.
|
TagFilter
|
Blobindextagbasierte Filterung für Blobobjekte
|
DateAfterCreation
Objekt, um Momentaufnahme- und Versionsaktionsbedingungen zu definieren.
Name |
Typ |
Beschreibung |
daysAfterCreationGreaterThan
|
number
|
Wert, der das Alter in Tagen nach der Erstellung angibt
|
daysAfterLastTierChangeGreaterThan
|
number
|
Wert, der das Alter in Tagen nach der letzten Blobebenenänderungszeit angibt. Diese Eigenschaft gilt nur für tierToArchive-Aktionen und erfordert, dass daysAfterCreationGreaterThan für Momentaufnahmen und blobversionsbasierte Aktionen festgelegt wird. Das Blob wird archiviert, wenn beide Bedingungen erfüllt sind.
|
DateAfterModification
Objekt zum Definieren der Basisblobaktionsbedingungen. Die Eigenschaften daysAfterModificationGreaterThan, daysAfterLastAccessTimeGreaterThan und daysAfterCreationGreaterThan schließen sich gegenseitig aus. Die daysAfterLastTierChangeGreaterThan-Eigenschaft gilt nur für tierToArchive-Aktionen, für die daysAfterModificationGreaterThan festgelegt werden muss. Außerdem kann sie nicht in Verbindung mit daysAfterLastAccessTimeGreaterThan oder daysAfterCreationGreaterThan verwendet werden.
Name |
Typ |
Beschreibung |
daysAfterCreationGreaterThan
|
number
|
Wert, der das Alter in Tagen nach der Bloberstellung angibt.
|
daysAfterLastAccessTimeGreaterThan
|
number
|
Wert, der das Alter in Tagen nach dem letzten Blobzugriff angibt. Diese Eigenschaft kann nur in Verbindung mit der Richtlinie zur Nachverfolgung der letzten Zugriffszeit verwendet werden.
|
daysAfterLastTierChangeGreaterThan
|
number
|
Wert, der das Alter in Tagen nach der letzten Blobebenenänderungszeit angibt. Diese Eigenschaft gilt nur für tierToArchive-Aktionen und erfordert das Festlegen von daysAfterModificationGreaterThan für baseBlobs-basierte Aktionen. Das Blob wird archiviert, wenn beide Bedingungen erfüllt sind.
|
daysAfterModificationGreaterThan
|
number
|
Wert, der das Alter in Tagen nach der letzten Änderung angibt
|
ManagementPolicy
Die Antwort des Vorgangs "Storage Account ManagementPolicies abrufen".
Name |
Typ |
Beschreibung |
id
|
string
|
Vollqualifizierte Ressourcen-ID für die Ressource. Beispiel: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
name
|
string
|
Der Name der Ressource
|
properties.lastModifiedTime
|
string
|
Gibt das Datum und die Uhrzeit der letzten Änderung des ManagementPolicies zurück.
|
properties.policy
|
ManagementPolicySchema
|
Die Speicherkontoverwaltungsrichtlinie im JSON-Format. Weitere Informationen finden Sie unter : https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts.
|
type
|
string
|
Der Typ der Ressource. Z. B. "Microsoft.Compute/virtualMachines" oder "Microsoft.Storage/storageAccounts"
|
ManagementPolicyAction
Aktionen werden auf die gefilterten Blobs angewendet, wenn die Ausführungsbedingung erfüllt ist.
ManagementPolicyBaseBlob
Verwaltungsrichtlinienaktion für Basisblob.
Name |
Typ |
Beschreibung |
delete
|
DateAfterModification
|
Die Funktion zum Löschen des Blobs
|
enableAutoTierToHotFromCool
|
boolean
|
Diese Eigenschaft ermöglicht das automatische Tiering eines Blobs von kalt bis heiß für einen Blobzugriff. Diese Eigenschaft erfordert tierToCool.daysAfterLastAccessTimeGreaterThan.
|
tierToArchive
|
DateAfterModification
|
Die Funktion zum Tierieren von Blobs zum Archivieren von Speicher.
|
tierToCold
|
DateAfterModification
|
Die Funktion zum Tierieren von Blobs in Cold Storage.
|
tierToCool
|
DateAfterModification
|
Die Funktion zum Tierieren von Blobs zum Kühlen des Speichers.
|
tierToHot
|
DateAfterModification
|
Die Funktion zum Tierieren von Blobs in Hot Storage. Diese Aktion kann nur mit Premium Block Blob Storage-Konten verwendet werden.
|
ManagementPolicyDefinition
Ein Objekt, das die Lebenszyklusregel definiert. Jede Definition beinhaltet einen Filtersatz und einen Aktionssatz.
ManagementPolicyFilter
Filter schränken Regelaktionen auf eine Teilmenge der Blobs innerhalb des Speicherkontos ein. Wenn mehrere Filter definiert sind, wird für alle Filter ein logisches AND ausgeführt.
Name |
Typ |
Beschreibung |
blobIndexMatch
|
TagFilter[]
|
Ein Array von Blobindextag-basierten Filtern, es können maximal 10 Tagfilter vorhanden sein.
|
blobTypes
|
string[]
|
Ein Array von vordefinierten Enumerationswerten. Derzeit unterstützt blockBlob alle Tiering- und Löschaktionen. Nur Löschaktionen werden für appendBlob unterstützt.
|
prefixMatch
|
string[]
|
Ein Array von Zeichenfolgen für Präfixe, mit denen Übereinstimmung erzielt werden soll.
|
ManagementPolicyName
Der Name der Speicherkontoverwaltungsrichtlinie. Es sollte immer "Standard" sein.
Name |
Typ |
Beschreibung |
default
|
string
|
|
ManagementPolicyRule
Ein Objekt, das die Lebenszyklusregel umschließt. Jede Regel ist eindeutig durch den Namen definiert.
Name |
Typ |
Beschreibung |
definition
|
ManagementPolicyDefinition
|
Ein Objekt, das die Lebenszyklusregel definiert.
|
enabled
|
boolean
|
Die Regel ist aktiviert, wenn sie auf true festgelegt ist.
|
name
|
string
|
Ein Regelname kann aus einer beliebigen Kombination von alphanumerischen Zeichen bestehen. Bei Regelnamen wird die Groß-/Kleinschreibung unterschieden. Er muss innerhalb einer Richtlinie eindeutig sein.
|
type
|
RuleType
|
Der gültige Wert ist Lifecycle.
|
ManagementPolicySchema
Die SpeicherkontoverwaltungRichtlinienregeln. Weitere Informationen finden Sie unter : https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts.
ManagementPolicySnapShot
Verwaltungsrichtlinienaktion für Momentaufnahme.
Name |
Typ |
Beschreibung |
delete
|
DateAfterCreation
|
Die Funktion zum Löschen des Blob-Momentaufnahme
|
tierToArchive
|
DateAfterCreation
|
Die Funktion zum Mehrstufen von Blobs Momentaufnahme zum Archivieren von Speicher.
|
tierToCold
|
DateAfterCreation
|
Die Funktion zum Tierieren von Blobs in Cold Storage.
|
tierToCool
|
DateAfterCreation
|
Die Funktion zum Tier-Blob Momentaufnahme zum Kühlen des Speichers.
|
tierToHot
|
DateAfterCreation
|
Die Funktion zum Tierieren von Blobs in Hot Storage. Diese Aktion kann nur mit Premium Block Blob Storage-Konten verwendet werden.
|
ManagementPolicyVersion
Verwaltungsrichtlinienaktion für Blobversion.
Name |
Typ |
Beschreibung |
delete
|
DateAfterCreation
|
Die Funktion zum Löschen der Blobversion
|
tierToArchive
|
DateAfterCreation
|
Die Funktion zum Tierieren der Blobversion zum Archivieren von Speicher.
|
tierToCold
|
DateAfterCreation
|
Die Funktion zum Tierieren von Blobs in Cold Storage.
|
tierToCool
|
DateAfterCreation
|
Die Funktion zum Tierieren der Blobversion zum Kühlen des Speichers.
|
tierToHot
|
DateAfterCreation
|
Die Funktion zum Tierieren von Blobs in Hot Storage. Diese Aktion kann nur mit Premium Block Blob Storage-Konten verwendet werden.
|
RuleType
Der gültige Wert ist Lifecycle.
Name |
Typ |
Beschreibung |
Lifecycle
|
string
|
|
TagFilter
Blobindextagbasierte Filterung für Blobobjekte
Name |
Typ |
Beschreibung |
name
|
string
|
Dies ist der Name des Filtertags, der aus 1 bis 128 Zeichen bestehen kann.
|
op
|
string
|
Dies ist der Vergleichsoperator, der für den Objektvergleich und die Filterung verwendet wird. Nur == (Gleichheitsoperator) wird derzeit unterstützt.
|
value
|
string
|
Dies ist das Filtertagwertfeld, das für die tagbasierte Filterung verwendet wird. Es kann 0 bis 256 Zeichen haben.
|