Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}?api-version=2023-05-01
URI Parameters
Name |
In |
Required |
Type |
Description |
accountName
|
path |
True
|
string
|
The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.
Regex pattern: ^[a-z0-9]+$
|
containerName
|
path |
True
|
string
|
The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number.
|
resourceGroupName
|
path |
True
|
string
|
The name of the resource group within the user's subscription. The name is case insensitive.
Regex pattern: ^[-\w\._\(\)]+$
|
subscriptionId
|
path |
True
|
string
|
The ID of the target subscription.
|
api-version
|
query |
True
|
string
|
The API version to use for this operation.
|
Request Body
Name |
Type |
Description |
properties.defaultEncryptionScope
|
string
|
Default the container to use specified encryption scope for all writes.
|
properties.denyEncryptionScopeOverride
|
boolean
|
Block override of encryption scope from the container default.
|
properties.enableNfsV3AllSquash
|
boolean
|
Enable NFSv3 all squash on blob container.
|
properties.enableNfsV3RootSquash
|
boolean
|
Enable NFSv3 root squash on blob container.
|
properties.immutableStorageWithVersioning
|
ImmutableStorageWithVersioning
|
The object level immutability property of the container. The property is immutable and can only be set to true at the container creation time. Existing containers must undergo a migration process.
|
properties.metadata
|
object
|
A name-value pair to associate with the container as metadata.
|
properties.publicAccess
|
PublicAccess
|
Specifies whether data in the container may be accessed publicly and the level of access.
|
Responses
Name |
Type |
Description |
200 OK
|
BlobContainer
|
OK -- The Container is already created.
|
201 Created
|
BlobContainer
|
Created -- Create Container operation completed successfully.
|
Security
azure_auth
Azure Active Directory OAuth2 Flow
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name |
Description |
user_impersonation
|
impersonate your user account
|
Examples
PutContainers
Sample request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/res3376/providers/Microsoft.Storage/storageAccounts/sto328/blobServices/default/containers/container6185?api-version=2023-05-01
{}
import com.azure.resourcemanager.storage.fluent.models.BlobContainerInner;
/**
* Samples for BlobContainers Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPut.json
*/
/**
* Sample code: PutContainers.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void putContainers(com.azure.resourcemanager.AzureResourceManager azure) {
azure.storageAccounts().manager().serviceClient().getBlobContainers().createWithResponse("res3376", "sto328",
"container6185", new BlobContainerInner(), 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
package armstorage_test
import (
"context"
"log"
"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/220ad9c6554fc7d6d10a89bdb441c1e3b36e3285/specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPut.json
func ExampleBlobContainersClient_Create_putContainers() {
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.NewBlobContainersClient().Create(ctx, "res3376", "sto328", "container6185", armstorage.BlobContainer{}, 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.BlobContainer = armstorage.BlobContainer{
// Name: to.Ptr("container6185"),
// Type: to.Ptr("Microsoft.Storage/storageAccounts/blobServices/containers"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res3376/providers/Microsoft.Storage/storageAccounts/sto328/blobServices/default/containers/container6185"),
// }
}
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 Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container.
*
* @summary Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container.
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPut.json
*/
async function putContainers() {
const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res3376";
const accountName = "sto328";
const containerName = "container6185";
const blobContainer = {};
const credential = new DefaultAzureCredential();
const client = new StorageManagementClient(credential, subscriptionId);
const result = await client.blobContainers.create(
resourceGroupName,
accountName,
containerName,
blobContainer,
);
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
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Storage.Models;
using Azure.ResourceManager.Storage;
// Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPut.json
// this example is just showing the usage of "BlobContainers_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BlobServiceResource created on azure
// for more information of creating BlobServiceResource, please refer to the document of BlobServiceResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "res3376";
string accountName = "sto328";
ResourceIdentifier blobServiceResourceId = BlobServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
BlobServiceResource blobService = client.GetBlobServiceResource(blobServiceResourceId);
// get the collection of this BlobContainerResource
BlobContainerCollection collection = blobService.GetBlobContainers();
// invoke the operation
string containerName = "container6185";
BlobContainerData data = new BlobContainerData();
ArmOperation<BlobContainerResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerName, data);
BlobContainerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BlobContainerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
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/res3376/providers/Microsoft.Storage/storageAccounts/sto328/blobServices/default/containers/container6185",
"name": "container6185",
"type": "Microsoft.Storage/storageAccounts/blobServices/containers"
}
{
"id": "/subscriptions/{subscription-id}/resourceGroups/res3376/providers/Microsoft.Storage/storageAccounts/sto328/blobServices/default/containers/container6185",
"name": "container6185",
"type": "Microsoft.Storage/storageAccounts/blobServices/containers"
}
PutContainerWithDefaultEncryptionScope
Sample request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/res3376/providers/Microsoft.Storage/storageAccounts/sto328/blobServices/default/containers/container6185?api-version=2023-05-01
{
"properties": {
"defaultEncryptionScope": "encryptionscope185",
"denyEncryptionScopeOverride": true
}
}
import com.azure.resourcemanager.storage.fluent.models.BlobContainerInner;
/**
* Samples for BlobContainers Create.
*/
public final class Main {
/*
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/
* BlobContainersPutDefaultEncryptionScope.json
*/
/**
* Sample code: PutContainerWithDefaultEncryptionScope.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void putContainerWithDefaultEncryptionScope(com.azure.resourcemanager.AzureResourceManager azure) {
azure.storageAccounts().manager().serviceClient().getBlobContainers().createWithResponse(
"res3376", "sto328", "container6185", new BlobContainerInner()
.withDefaultEncryptionScope("encryptionscope185").withDenyEncryptionScopeOverride(true),
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
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/220ad9c6554fc7d6d10a89bdb441c1e3b36e3285/specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPutDefaultEncryptionScope.json
func ExampleBlobContainersClient_Create_putContainerWithDefaultEncryptionScope() {
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.NewBlobContainersClient().Create(ctx, "res3376", "sto328", "container6185", armstorage.BlobContainer{
ContainerProperties: &armstorage.ContainerProperties{
DefaultEncryptionScope: to.Ptr("encryptionscope185"),
DenyEncryptionScopeOverride: 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.BlobContainer = armstorage.BlobContainer{
// Name: to.Ptr("container6185"),
// Type: to.Ptr("Microsoft.Storage/storageAccounts/blobServices/containers"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res3376/providers/Microsoft.Storage/storageAccounts/sto328/blobServices/default/containers/container6185"),
// ContainerProperties: &armstorage.ContainerProperties{
// DefaultEncryptionScope: to.Ptr("encryptionscope185"),
// DenyEncryptionScopeOverride: 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 Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container.
*
* @summary Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container.
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPutDefaultEncryptionScope.json
*/
async function putContainerWithDefaultEncryptionScope() {
const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res3376";
const accountName = "sto328";
const containerName = "container6185";
const blobContainer = {
defaultEncryptionScope: "encryptionscope185",
denyEncryptionScopeOverride: true,
};
const credential = new DefaultAzureCredential();
const client = new StorageManagementClient(credential, subscriptionId);
const result = await client.blobContainers.create(
resourceGroupName,
accountName,
containerName,
blobContainer,
);
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
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Storage.Models;
using Azure.ResourceManager.Storage;
// Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPutDefaultEncryptionScope.json
// this example is just showing the usage of "BlobContainers_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BlobServiceResource created on azure
// for more information of creating BlobServiceResource, please refer to the document of BlobServiceResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "res3376";
string accountName = "sto328";
ResourceIdentifier blobServiceResourceId = BlobServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
BlobServiceResource blobService = client.GetBlobServiceResource(blobServiceResourceId);
// get the collection of this BlobContainerResource
BlobContainerCollection collection = blobService.GetBlobContainers();
// invoke the operation
string containerName = "container6185";
BlobContainerData data = new BlobContainerData()
{
DefaultEncryptionScope = "encryptionscope185",
PreventEncryptionScopeOverride = true,
};
ArmOperation<BlobContainerResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerName, data);
BlobContainerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BlobContainerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from typing import Any, IO, Union
from azure.identity import DefaultAzureCredential
from azure.mgmt.storage import StorageManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-storage
# USAGE
python blob_containers_put_default_encryption_scope.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.blob_containers.create(
resource_group_name="res3376",
account_name="sto328",
container_name="container6185",
blob_container={
"properties": {"defaultEncryptionScope": "encryptionscope185", "denyEncryptionScopeOverride": True}
},
)
print(response)
# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPutDefaultEncryptionScope.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
Sample response
{
"id": "/subscriptions/{subscription-id}/resourceGroups/res3376/providers/Microsoft.Storage/storageAccounts/sto328/blobServices/default/containers/container6185",
"name": "container6185",
"type": "Microsoft.Storage/storageAccounts/blobServices/containers",
"properties": {
"defaultEncryptionScope": "encryptionscope185",
"denyEncryptionScopeOverride": true
}
}
{
"id": "/subscriptions/{subscription-id}/resourceGroups/res3376/providers/Microsoft.Storage/storageAccounts/sto328/blobServices/default/containers/container6185",
"name": "container6185",
"type": "Microsoft.Storage/storageAccounts/blobServices/containers",
"properties": {
"defaultEncryptionScope": "encryptionscope185",
"denyEncryptionScopeOverride": true
}
}
PutContainerWithObjectLevelWorm
Sample request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/res3376/providers/Microsoft.Storage/storageAccounts/sto328/blobServices/default/containers/container6185?api-version=2023-05-01
{
"properties": {
"immutableStorageWithVersioning": {
"enabled": true
}
}
}
import com.azure.resourcemanager.storage.fluent.models.BlobContainerInner;
import com.azure.resourcemanager.storage.models.ImmutableStorageWithVersioning;
/**
* Samples for BlobContainers Create.
*/
public final class Main {
/*
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/
* BlobContainersPutObjectLevelWorm.json
*/
/**
* Sample code: PutContainerWithObjectLevelWorm.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void putContainerWithObjectLevelWorm(com.azure.resourcemanager.AzureResourceManager azure) {
azure.storageAccounts().manager().serviceClient().getBlobContainers()
.createWithResponse("res3376", "sto328", "container6185", new BlobContainerInner()
.withImmutableStorageWithVersioning(new ImmutableStorageWithVersioning().withEnabled(true)),
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
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/220ad9c6554fc7d6d10a89bdb441c1e3b36e3285/specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPutObjectLevelWorm.json
func ExampleBlobContainersClient_Create_putContainerWithObjectLevelWorm() {
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.NewBlobContainersClient().Create(ctx, "res3376", "sto328", "container6185", armstorage.BlobContainer{
ContainerProperties: &armstorage.ContainerProperties{
ImmutableStorageWithVersioning: &armstorage.ImmutableStorageWithVersioning{
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.BlobContainer = armstorage.BlobContainer{
// Name: to.Ptr("container6185"),
// Type: to.Ptr("Microsoft.Storage/storageAccounts/blobServices/containers"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res3376/providers/Microsoft.Storage/storageAccounts/sto328/blobServices/default/containers/container6185"),
// ContainerProperties: &armstorage.ContainerProperties{
// ImmutableStorageWithVersioning: &armstorage.ImmutableStorageWithVersioning{
// 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 Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container.
*
* @summary Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container.
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPutObjectLevelWorm.json
*/
async function putContainerWithObjectLevelWorm() {
const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res3376";
const accountName = "sto328";
const containerName = "container6185";
const blobContainer = {
immutableStorageWithVersioning: { enabled: true },
};
const credential = new DefaultAzureCredential();
const client = new StorageManagementClient(credential, subscriptionId);
const result = await client.blobContainers.create(
resourceGroupName,
accountName,
containerName,
blobContainer,
);
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
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Storage.Models;
using Azure.ResourceManager.Storage;
// Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPutObjectLevelWorm.json
// this example is just showing the usage of "BlobContainers_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BlobServiceResource created on azure
// for more information of creating BlobServiceResource, please refer to the document of BlobServiceResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "res3376";
string accountName = "sto328";
ResourceIdentifier blobServiceResourceId = BlobServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName);
BlobServiceResource blobService = client.GetBlobServiceResource(blobServiceResourceId);
// get the collection of this BlobContainerResource
BlobContainerCollection collection = blobService.GetBlobContainers();
// invoke the operation
string containerName = "container6185";
BlobContainerData data = new BlobContainerData()
{
ImmutableStorageWithVersioning = new ImmutableStorageWithVersioning()
{
IsEnabled = true,
},
};
ArmOperation<BlobContainerResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerName, data);
BlobContainerResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
BlobContainerData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from typing import Any, IO, Union
from azure.identity import DefaultAzureCredential
from azure.mgmt.storage import StorageManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-storage
# USAGE
python blob_containers_put_object_level_worm.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.blob_containers.create(
resource_group_name="res3376",
account_name="sto328",
container_name="container6185",
blob_container={"properties": {"immutableStorageWithVersioning": {"enabled": True}}},
)
print(response)
# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPutObjectLevelWorm.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
Sample response
{
"id": "/subscriptions/{subscription-id}/resourceGroups/res3376/providers/Microsoft.Storage/storageAccounts/sto328/blobServices/default/containers/container6185",
"name": "container6185",
"type": "Microsoft.Storage/storageAccounts/blobServices/containers",
"properties": {
"immutableStorageWithVersioning": {
"enabled": true
}
}
}
{
"id": "/subscriptions/{subscription-id}/resourceGroups/res3376/providers/Microsoft.Storage/storageAccounts/sto328/blobServices/default/containers/container6185",
"name": "container6185",
"type": "Microsoft.Storage/storageAccounts/blobServices/containers",
"properties": {
"immutableStorageWithVersioning": {
"enabled": true
}
}
}
Definitions
BlobContainer
Properties of the blob container, including Id, resource name, resource type, Etag.
Name |
Type |
Description |
etag
|
string
|
Resource Etag.
|
id
|
string
|
Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
name
|
string
|
The name of the resource
|
properties.defaultEncryptionScope
|
string
|
Default the container to use specified encryption scope for all writes.
|
properties.deleted
|
boolean
|
Indicates whether the blob container was deleted.
|
properties.deletedTime
|
string
|
Blob container deletion time.
|
properties.denyEncryptionScopeOverride
|
boolean
|
Block override of encryption scope from the container default.
|
properties.enableNfsV3AllSquash
|
boolean
|
Enable NFSv3 all squash on blob container.
|
properties.enableNfsV3RootSquash
|
boolean
|
Enable NFSv3 root squash on blob container.
|
properties.hasImmutabilityPolicy
|
boolean
|
The hasImmutabilityPolicy public property is set to true by SRP if ImmutabilityPolicy has been created for this container. The hasImmutabilityPolicy public property is set to false by SRP if ImmutabilityPolicy has not been created for this container.
|
properties.hasLegalHold
|
boolean
|
The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold public property is set to false by SRP if all existing legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account.
|
properties.immutabilityPolicy
|
ImmutabilityPolicyProperties
|
The ImmutabilityPolicy property of the container.
|
properties.immutableStorageWithVersioning
|
ImmutableStorageWithVersioning
|
The object level immutability property of the container. The property is immutable and can only be set to true at the container creation time. Existing containers must undergo a migration process.
|
properties.lastModifiedTime
|
string
|
Returns the date and time the container was last modified.
|
properties.leaseDuration
|
LeaseDuration
|
Specifies whether the lease on a container is of infinite or fixed duration, only when the container is leased.
|
properties.leaseState
|
LeaseState
|
Lease state of the container.
|
properties.leaseStatus
|
LeaseStatus
|
The lease status of the container.
|
properties.legalHold
|
LegalHoldProperties
|
The LegalHold property of the container.
|
properties.metadata
|
object
|
A name-value pair to associate with the container as metadata.
|
properties.publicAccess
|
PublicAccess
|
Specifies whether data in the container may be accessed publicly and the level of access.
|
properties.remainingRetentionDays
|
integer
|
Remaining retention days for soft deleted blob container.
|
properties.version
|
string
|
The version of the deleted blob container.
|
type
|
string
|
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
|
ImmutabilityPolicyProperties
The properties of an ImmutabilityPolicy of a blob container.
Name |
Type |
Description |
etag
|
string
|
ImmutabilityPolicy Etag.
|
properties.allowProtectedAppendWrites
|
boolean
|
This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining immutability protection and compliance. Only new blocks can be added and any existing blocks cannot be modified or deleted. This property cannot be changed with ExtendImmutabilityPolicy API.
|
properties.allowProtectedAppendWritesAll
|
boolean
|
This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to both 'Append and Bock Blobs' while maintaining immutability protection and compliance. Only new blocks can be added and any existing blocks cannot be modified or deleted. This property cannot be changed with ExtendImmutabilityPolicy API. The 'allowProtectedAppendWrites' and 'allowProtectedAppendWritesAll' properties are mutually exclusive.
|
properties.immutabilityPeriodSinceCreationInDays
|
integer
|
The immutability period for the blobs in the container since the policy creation, in days.
|
properties.state
|
ImmutabilityPolicyState
|
The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked.
|
updateHistory
|
UpdateHistoryProperty[]
|
The ImmutabilityPolicy update history of the blob container.
|
ImmutabilityPolicyState
The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked.
Name |
Type |
Description |
Locked
|
string
|
|
Unlocked
|
string
|
|
ImmutabilityPolicyUpdateType
The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend.
Name |
Type |
Description |
extend
|
string
|
|
lock
|
string
|
|
put
|
string
|
|
ImmutableStorageWithVersioning
Object level immutability properties of the container.
Name |
Type |
Description |
enabled
|
boolean
|
This is an immutable property, when set to true it enables object level immutability at the container level.
|
migrationState
|
MigrationState
|
This property denotes the container level immutability to object level immutability migration state.
|
timeStamp
|
string
|
Returns the date and time the object level immutability was enabled.
|
LeaseDuration
Specifies whether the lease on a container is of infinite or fixed duration, only when the container is leased.
Name |
Type |
Description |
Fixed
|
string
|
|
Infinite
|
string
|
|
LeaseState
Lease state of the container.
Name |
Type |
Description |
Available
|
string
|
|
Breaking
|
string
|
|
Broken
|
string
|
|
Expired
|
string
|
|
Leased
|
string
|
|
LeaseStatus
The lease status of the container.
Name |
Type |
Description |
Locked
|
string
|
|
Unlocked
|
string
|
|
LegalHoldProperties
The LegalHold property of a blob container.
Name |
Type |
Description |
hasLegalHold
|
boolean
|
The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold public property is set to false by SRP if all existing legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account.
|
protectedAppendWritesHistory
|
ProtectedAppendWritesHistory
|
Protected append blob writes history.
|
tags
|
TagProperty[]
|
The list of LegalHold tags of a blob container.
|
MigrationState
This property denotes the container level immutability to object level immutability migration state.
Name |
Type |
Description |
Completed
|
string
|
|
InProgress
|
string
|
|
ProtectedAppendWritesHistory
Protected append writes history setting for the blob container with Legal holds.
Name |
Type |
Description |
allowProtectedAppendWritesAll
|
boolean
|
When enabled, new blocks can be written to both 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks can be added and any existing blocks cannot be modified or deleted.
|
timestamp
|
string
|
Returns the date and time the tag was added.
|
PublicAccess
Specifies whether data in the container may be accessed publicly and the level of access.
Name |
Type |
Description |
Blob
|
string
|
|
Container
|
string
|
|
None
|
string
|
|
TagProperty
A tag of the LegalHold of a blob container.
Name |
Type |
Description |
objectIdentifier
|
string
|
Returns the Object ID of the user who added the tag.
|
tag
|
string
|
The tag value.
|
tenantId
|
string
|
Returns the Tenant ID that issued the token for the user who added the tag.
|
timestamp
|
string
|
Returns the date and time the tag was added.
|
upn
|
string
|
Returns the User Principal Name of the user who added the tag.
|
UpdateHistoryProperty
An update history of the ImmutabilityPolicy of a blob container.
Name |
Type |
Description |
allowProtectedAppendWrites
|
boolean
|
This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining immutability protection and compliance. Only new blocks can be added and any existing blocks cannot be modified or deleted. This property cannot be changed with ExtendImmutabilityPolicy API.
|
allowProtectedAppendWritesAll
|
boolean
|
This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to both 'Append and Bock Blobs' while maintaining immutability protection and compliance. Only new blocks can be added and any existing blocks cannot be modified or deleted. This property cannot be changed with ExtendImmutabilityPolicy API. The 'allowProtectedAppendWrites' and 'allowProtectedAppendWritesAll' properties are mutually exclusive.
|
immutabilityPeriodSinceCreationInDays
|
integer
|
The immutability period for the blobs in the container since the policy creation, in days.
|
objectIdentifier
|
string
|
Returns the Object ID of the user who updated the ImmutabilityPolicy.
|
tenantId
|
string
|
Returns the Tenant ID that issued the token for the user who updated the ImmutabilityPolicy.
|
timestamp
|
string
|
Returns the date and time the ImmutabilityPolicy was updated.
|
update
|
ImmutabilityPolicyUpdateType
|
The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend.
|
upn
|
string
|
Returns the User Principal Name of the user who updated the ImmutabilityPolicy.
|