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

285 lines
13 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 blob inventory policy to the specified storage account.
*
* @summary Sets the blob inventory policy to the specified storage account.
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2021-09-01/examples/StorageAccountSetBlobInventoryPolicy.json
*/
function storageAccountSetBlobInventoryPolicy() {
return __awaiter(this, void 0, void 0, function* () {
const subscriptionId = "{subscription-id}";
const resourceGroupName = "res7687";
const accountName = "sto9699";
const blobInventoryPolicyName = "default";
const properties = {
policy: {
type: "Inventory",
enabled: true,
rules: [
{
name: "inventoryPolicyRule1",
definition: {
format: "Csv",
filters: {
blobTypes: ["blockBlob", "appendBlob", "pageBlob"],
excludePrefix: ["excludeprefix1", "excludeprefix2"],
includeBlobVersions: true,
includeSnapshots: true,
prefixMatch: ["inventoryprefix1", "inventoryprefix2"]
},
objectType: "Blob",
schedule: "Daily",
schemaFields: [
"Name",
"Creation-Time",
"Last-Modified",
"Content-Length",
"Content-MD5",
"BlobType",
"AccessTier",
"AccessTierChangeTime",
"Snapshot",
"VersionId",
"IsCurrentVersion",
"Metadata"
]
},
destination: "container1",
enabled: true
},
{
name: "inventoryPolicyRule2",
definition: {
format: "Parquet",
objectType: "Container",
schedule: "Weekly",
schemaFields: [
"Name",
"Last-Modified",
"Metadata",
"LeaseStatus",
"LeaseState",
"LeaseDuration",
"PublicAccess",
"HasImmutabilityPolicy",
"HasLegalHold"
]
},
destination: "container2",
enabled: true
}
]
}
};
const credential = new DefaultAzureCredential();
const client = new StorageManagementClient(credential, subscriptionId);
const result = yield client.blobInventoryPolicies.createOrUpdate(resourceGroupName, accountName, blobInventoryPolicyName, properties);
console.log(result);
});
}
storageAccountSetBlobInventoryPolicy().catch(console.error);
/**
* This sample demonstrates how to Sets the blob inventory policy to the specified storage account.
*
* @summary Sets the blob inventory policy to the specified storage account.
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2021-09-01/examples/StorageAccountSetBlobInventoryPolicyIncludeDeleteAndNewSchemaForHnsAccount.json
*/
function storageAccountSetBlobInventoryPolicyIncludeDeleteAndNewSchemaForHnsAccount() {
return __awaiter(this, void 0, void 0, function* () {
const subscriptionId = "{subscription-id}";
const resourceGroupName = "res7687";
const accountName = "sto9699";
const blobInventoryPolicyName = "default";
const properties = {
policy: {
type: "Inventory",
enabled: true,
rules: [
{
name: "inventoryPolicyRule1",
definition: {
format: "Csv",
filters: {
blobTypes: ["blockBlob", "appendBlob", "pageBlob"],
excludePrefix: ["excludeprefix1", "excludeprefix2"],
includeBlobVersions: true,
includeDeleted: true,
includeSnapshots: true,
prefixMatch: ["inventoryprefix1", "inventoryprefix2"]
},
objectType: "Blob",
schedule: "Daily",
schemaFields: [
"Name",
"Creation-Time",
"Last-Modified",
"Content-Length",
"Content-MD5",
"BlobType",
"AccessTier",
"AccessTierChangeTime",
"Snapshot",
"VersionId",
"IsCurrentVersion",
"ContentType",
"ContentEncoding",
"ContentLanguage",
"ContentCRC64",
"CacheControl",
"Metadata",
"DeletionId",
"Deleted",
"DeletedTime",
"RemainingRetentionDays"
]
},
destination: "container1",
enabled: true
},
{
name: "inventoryPolicyRule2",
definition: {
format: "Parquet",
objectType: "Container",
schedule: "Weekly",
schemaFields: [
"Name",
"Last-Modified",
"Metadata",
"LeaseStatus",
"LeaseState",
"LeaseDuration",
"PublicAccess",
"HasImmutabilityPolicy",
"HasLegalHold",
"Etag",
"DefaultEncryptionScope",
"DenyEncryptionScopeOverride",
"ImmutableStorageWithVersioningEnabled",
"Deleted",
"Version",
"DeletedTime",
"RemainingRetentionDays"
]
},
destination: "container2",
enabled: true
}
]
}
};
const credential = new DefaultAzureCredential();
const client = new StorageManagementClient(credential, subscriptionId);
const result = yield client.blobInventoryPolicies.createOrUpdate(resourceGroupName, accountName, blobInventoryPolicyName, properties);
console.log(result);
});
}
storageAccountSetBlobInventoryPolicyIncludeDeleteAndNewSchemaForHnsAccount().catch(console.error);
/**
* This sample demonstrates how to Sets the blob inventory policy to the specified storage account.
*
* @summary Sets the blob inventory policy to the specified storage account.
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2021-09-01/examples/StorageAccountSetBlobInventoryPolicyIncludeDeleteAndNewSchemaForNonHnsAccount.json
*/
function storageAccountSetBlobInventoryPolicyIncludeDeleteAndNewSchemaForNonHnsAccount() {
return __awaiter(this, void 0, void 0, function* () {
const subscriptionId = "{subscription-id}";
const resourceGroupName = "res7687";
const accountName = "sto9699";
const blobInventoryPolicyName = "default";
const properties = {
policy: {
type: "Inventory",
enabled: true,
rules: [
{
name: "inventoryPolicyRule1",
definition: {
format: "Csv",
filters: {
blobTypes: ["blockBlob", "appendBlob", "pageBlob"],
excludePrefix: ["excludeprefix1", "excludeprefix2"],
includeBlobVersions: true,
includeDeleted: true,
includeSnapshots: true,
prefixMatch: ["inventoryprefix1", "inventoryprefix2"]
},
objectType: "Blob",
schedule: "Daily",
schemaFields: [
"Name",
"Creation-Time",
"Last-Modified",
"Content-Length",
"Content-MD5",
"BlobType",
"AccessTier",
"AccessTierChangeTime",
"Snapshot",
"VersionId",
"IsCurrentVersion",
"Tags",
"ContentType",
"ContentEncoding",
"ContentLanguage",
"ContentCRC64",
"CacheControl",
"Metadata",
"Deleted",
"RemainingRetentionDays"
]
},
destination: "container1",
enabled: true
},
{
name: "inventoryPolicyRule2",
definition: {
format: "Parquet",
objectType: "Container",
schedule: "Weekly",
schemaFields: [
"Name",
"Last-Modified",
"Metadata",
"LeaseStatus",
"LeaseState",
"LeaseDuration",
"PublicAccess",
"HasImmutabilityPolicy",
"HasLegalHold",
"Etag",
"DefaultEncryptionScope",
"DenyEncryptionScopeOverride",
"ImmutableStorageWithVersioningEnabled",
"Deleted",
"Version",
"DeletedTime",
"RemainingRetentionDays"
]
},
destination: "container2",
enabled: true
}
]
}
};
const credential = new DefaultAzureCredential();
const client = new StorageManagementClient(credential, subscriptionId);
const result = yield client.blobInventoryPolicies.createOrUpdate(resourceGroupName, accountName, blobInventoryPolicyName, properties);
console.log(result);
});
}
storageAccountSetBlobInventoryPolicyIncludeDeleteAndNewSchemaForNonHnsAccount().catch(console.error);
//# sourceMappingURL=blobInventoryPoliciesCreateOrUpdateSample.js.map