I'm creating several storage accounts programmatically via StorageManagementClient
and would like to enable blob versioning on account level at the time of account creation. How is this accomplished?
var storageManagementClient = new StorageManagementClient(azureCredentials)
{
SubscriptionId = subscriptionId
};
var storageAccountCreateParameters = new StorageAccountCreateParameters
{
// set properties
};
await storageManagementClient.StorageAccounts.CreateAsync(resourceGroupName, accountName, storageAccountCreateParameters);
I thought that this would be available as a create parameter in StorageAccountCreateParameters
, but I don't see anything there.
Also see https://docs.microsoft.com/en-us/azure/storage/blobs/versioning-enable?tabs=portal
The blob versioning
is not included in the StorageAccountCreateParameters
. It belongs to BlobServiceProperties class.
So after you create the storage account with your code above, you can use the following code to set blob versioning
:
var p1 = new BlobServiceProperties()
{
IsVersioningEnabled = true
};
storageManagementClient.BlobServices.SetServiceProperties("resource_group", "account_name", p1);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.