Files
2025-03-07 19:22:02 +01:00

319 lines
15 KiB
JavaScript

/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { __awaiter } from "tslib";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { StorageManagementClient } from "@azure/arm-storage";
import { DefaultAzureCredential } from "@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/2021-09-01/examples/StorageAccountSetManagementPolicy.json
*/
function storageAccountSetManagementPolicies() {
return __awaiter(this, void 0, void 0, function* () {
const subscriptionId = "{subscription-id}";
const resourceGroupName = "res7687";
const accountName = "sto9699";
const managementPolicyName = "default";
const properties = {
policy: {
rules: [
{
name: "olcmtest1",
type: "Lifecycle",
definition: {
actions: {
baseBlob: {
delete: { daysAfterModificationGreaterThan: 1000 },
tierToArchive: { daysAfterModificationGreaterThan: 90 },
tierToCool: { daysAfterModificationGreaterThan: 30 }
},
snapshot: { delete: { daysAfterCreationGreaterThan: 30 } }
},
filters: {
blobTypes: ["blockBlob"],
prefixMatch: ["olcmtestcontainer1"]
}
},
enabled: true
},
{
name: "olcmtest2",
type: "Lifecycle",
definition: {
actions: {
baseBlob: {
delete: { daysAfterModificationGreaterThan: 1000 },
tierToArchive: { daysAfterModificationGreaterThan: 90 },
tierToCool: { daysAfterModificationGreaterThan: 30 }
}
},
filters: {
blobIndexMatch: [
{ name: "tag1", op: "==", value: "val1" },
{ name: "tag2", op: "==", value: "val2" }
],
blobTypes: ["blockBlob"],
prefixMatch: ["olcmtestcontainer2"]
}
},
enabled: true
}
]
}
};
const credential = new DefaultAzureCredential();
const client = new StorageManagementClient(credential, subscriptionId);
const result = yield client.managementPolicies.createOrUpdate(resourceGroupName, accountName, managementPolicyName, properties);
console.log(result);
});
}
storageAccountSetManagementPolicies().catch(console.error);
/**
* 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/2021-09-01/examples/StorageAccountSetManagementPolicyForBlockAndAppendBlobs.json
*/
function storageAccountSetManagementPolicyForBlockAndAppendBlobs() {
return __awaiter(this, void 0, void 0, function* () {
const subscriptionId = "{subscription-id}";
const resourceGroupName = "res7687";
const accountName = "sto9699";
const managementPolicyName = "default";
const properties = {
policy: {
rules: [
{
name: "olcmtest1",
type: "Lifecycle",
definition: {
actions: {
baseBlob: { delete: { daysAfterModificationGreaterThan: 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 = yield client.managementPolicies.createOrUpdate(resourceGroupName, accountName, managementPolicyName, properties);
console.log(result);
});
}
storageAccountSetManagementPolicyForBlockAndAppendBlobs().catch(console.error);
/**
* 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/2021-09-01/examples/StorageAccountSetManagementPolicyWithSnapshotAndVersion.json
*/
function storageAccountSetManagementPolicyWithSnapshotAndVersion() {
return __awaiter(this, void 0, void 0, function* () {
const subscriptionId = "{subscription-id}";
const resourceGroupName = "res7687";
const accountName = "sto9699";
const managementPolicyName = "default";
const properties = {
policy: {
rules: [
{
name: "olcmtest1",
type: "Lifecycle",
definition: {
actions: {
baseBlob: {
delete: { daysAfterModificationGreaterThan: 1000 },
tierToArchive: { daysAfterModificationGreaterThan: 90 },
tierToCool: { daysAfterModificationGreaterThan: 30 }
},
snapshot: {
delete: { daysAfterCreationGreaterThan: 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 = yield client.managementPolicies.createOrUpdate(resourceGroupName, accountName, managementPolicyName, properties);
console.log(result);
});
}
storageAccountSetManagementPolicyWithSnapshotAndVersion().catch(console.error);
/**
* 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/2021-09-01/examples/StorageAccountSetManagementPolicy_BaseBlobDaysAfterCreationActions.json
*/
function storageAccountSetManagementPolicyBaseBlobDaysAfterCreationActions() {
return __awaiter(this, void 0, void 0, function* () {
const subscriptionId = "{subscription-id}";
const resourceGroupName = "res7687";
const accountName = "sto9699";
const managementPolicyName = "default";
const properties = {
policy: {
rules: [
{
name: "olcmtest1",
type: "Lifecycle",
definition: {
actions: {
baseBlob: {
delete: { 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 = yield client.managementPolicies.createOrUpdate(resourceGroupName, accountName, managementPolicyName, properties);
console.log(result);
});
}
storageAccountSetManagementPolicyBaseBlobDaysAfterCreationActions().catch(console.error);
/**
* 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/2021-09-01/examples/StorageAccountSetManagementPolicy_LastAccessTimeBasedBlobActions.json
*/
function storageAccountSetManagementPolicyLastAccessTimeBasedBlobActions() {
return __awaiter(this, void 0, void 0, function* () {
const subscriptionId = "{subscription-id}";
const resourceGroupName = "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 = yield client.managementPolicies.createOrUpdate(resourceGroupName, accountName, managementPolicyName, properties);
console.log(result);
});
}
storageAccountSetManagementPolicyLastAccessTimeBasedBlobActions().catch(console.error);
/**
* 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/2021-09-01/examples/StorageAccountSetManagementPolicy_LastTierChangeTimeActions.json
*/
function storageAccountSetManagementPolicyLastTierChangeTimeActions() {
return __awaiter(this, void 0, void 0, function* () {
const subscriptionId = "{subscription-id}";
const resourceGroupName = "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 = yield client.managementPolicies.createOrUpdate(resourceGroupName, accountName, managementPolicyName, properties);
console.log(result);
});
}
storageAccountSetManagementPolicyLastTierChangeTimeActions().catch(console.error);
//# sourceMappingURL=managementPoliciesCreateOrUpdateSample.js.map