Edit

New-AzRmStorageContainer

Creates a Storage blob container

Syntax

AccountName (Default)

New-AzRmStorageContainer
    [-ResourceGroupName] <String>
    [-StorageAccountName] <String>
    -Name <String>
    [-PublicAccess <PSPublicAccess>]
    [-Metadata <Hashtable>]
    [-RootSquash <String>]
    [-BlobAccessPointConfigurationName <String>]
    [-BlobAccessPointConfigurationUniqueId <String>]
    [-EnableImmutableStorageWithVersioning]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

AccountNameEncryptionScope

New-AzRmStorageContainer
    [-ResourceGroupName] <String>
    [-StorageAccountName] <String>
    -Name <String>
    -DefaultEncryptionScope <String>
    -PreventEncryptionScopeOverride <Boolean>
    [-PublicAccess <PSPublicAccess>]
    [-Metadata <Hashtable>]
    [-RootSquash <String>]
    [-BlobAccessPointConfigurationName <String>]
    [-BlobAccessPointConfigurationUniqueId <String>]
    [-EnableImmutableStorageWithVersioning]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

AccountObject

New-AzRmStorageContainer
    -StorageAccount <PSStorageAccount>
    -Name <String>
    [-PublicAccess <PSPublicAccess>]
    [-Metadata <Hashtable>]
    [-RootSquash <String>]
    [-BlobAccessPointConfigurationName <String>]
    [-BlobAccessPointConfigurationUniqueId <String>]
    [-EnableImmutableStorageWithVersioning]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

AccountObjectEncryptionScope

New-AzRmStorageContainer
    -StorageAccount <PSStorageAccount>
    -Name <String>
    -DefaultEncryptionScope <String>
    -PreventEncryptionScopeOverride <Boolean>
    [-PublicAccess <PSPublicAccess>]
    [-Metadata <Hashtable>]
    [-RootSquash <String>]
    [-BlobAccessPointConfigurationName <String>]
    [-BlobAccessPointConfigurationUniqueId <String>]
    [-EnableImmutableStorageWithVersioning]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

The New-AzRmStorageContainer cmdlet creates a Storage blob container

Examples

Example 1: Create a Storage blob container with Storage account name and container name, with metadata

New-AzRmStorageContainer -ResourceGroupName "myResourceGroup" -AccountName "myStorageAccount" -ContainerName "myContainer" -Metadata @{tag0="value0";tag1="value1";tag2="value2"}

This command creates a Storage blob container with Storage account name and container name, with metadata.

Example 2: Create a Storage blob container with Storage account object and container name, with public access as Blob

$accountObject = Get-AzStorageAccount -ResourceGroupName "myResourceGroup" -AccountName "myStorageAccount"
New-AzRmStorageContainer -StorageAccount $accountObject -ContainerName "myContainer" -PublicAccess Blob

This command creates a Storage blob container with Storage account object and container name, with public access as Blob.

Example 3: Create a storage container with EncryptionScope setting

$c = New-AzRmStorageContainer -ResourceGroupName "myResourceGroup" -AccountName "mystorageaccount" -Name testcontainer -DefaultEncryptionScope "testscope" -PreventEncryptionScopeOverride $true

$c

   ResourceGroupName: myResourceGroup, StorageAccountName: mystorageaccount

Name          PublicAccess LastModified HasLegalHold HasImmutabilityPolicy
----          ------------ ------------ ------------ ---------------------
testcontainer                           False        False

$c.DefaultEncryptionScope
testscope

$c.DenyEncryptionScopeOverride
True

This command creates a storage container with a default encryptionScope, and blocks override of encryption scope from the container default. Then show the related container properties.

Example 4: Create an Azure storage container with RootSquash

$container = New-AzRmStorageContainer -ResourceGroupName "myrsourcegroup" -AccountName "mystorageaccount" -Name "mycontainer" -RootSquash AllSquash

$container.EnableNfsV3AllSquash
True

$container.EnableNfsV3RootSquash
False

This command creates a storage container, with RootSquash property set as AllSquash. RootSquash only works on a storage account that enabled NfsV3.

Example 5: Create a storage container and enable immutable Storage with versioning

$c = New-AzRmStorageContainer -ResourceGroupName "myResourceGroup" -AccountName "mystorageaccount" -Name testcontainer -EnableImmutableStorageWithVersioning

$c
ResourceGroupName: myResourceGroup, StorageAccountName: mystorageaccount

Name          PublicAccess LastModified         HasLegalHold HasImmutabilityPolicy Deleted VersionId ImmutableStorageWithVersioning
----          ------------ ------------         ------------ --------------------- ------- --------- ------------------------------
testcontainer None         2021-07-19 08:26:19Z False        False                 False             True

This command creates a storage container and enable immutable Storage with versioning. The command only works when the Storage account has already enabled blob versioning.

Example 6: Attach a Blob Access Point configuration when creating a container

$configuration = Get-AzStorageBlobAccessPointConfiguration -ResourceGroupName "myResourceGroup" -AccountName "mystorageaccount" -Name "myaccesspoint"
New-AzRmStorageContainer -ResourceGroupName "myResourceGroup" -StorageAccountName "mystorageaccount" -Name "mycontainer" -BlobAccessPointConfigurationName $configuration.Name -BlobAccessPointConfigurationUniqueId $configuration.UniqueId

Creates the container attached to the specified Blob Access Point configuration using its name and unique ID. The attachment cannot be added, changed, or removed after the container is created.

Parameters

-BlobAccessPointConfigurationName

Name of the Blob Access Point configuration to attach to the container.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-BlobAccessPointConfigurationUniqueId

Unique ID of the Blob Access Point configuration.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DefaultEncryptionScope

Default the container to use specified encryption scope for all writes.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

AccountNameEncryptionScope
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
AccountObjectEncryptionScope
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure.

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzContext, AzureRmContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-EnableImmutableStorageWithVersioning

Enable immutable Storage with versioning at the container level.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Metadata

Container Metadata

Parameter properties

Type:Hashtable
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Name

Container Name

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:N, ContainerName

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:True
Value from remaining arguments:False

-PreventEncryptionScopeOverride

Block override of encryption scope from the container default.

Parameter properties

Type:Boolean
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

AccountNameEncryptionScope
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
AccountObjectEncryptionScope
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-PublicAccess

Container PublicAccess

Parameter properties

Type:PSPublicAccess
Default value:None
Accepted values:Container, Blob, None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ResourceGroupName

Resource Group Name.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

AccountName
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
AccountNameEncryptionScope
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-RootSquash

Sets reduction of the access rights for the remote superuser. Possible values include: 'NoRootSquash', 'RootSquash', 'AllSquash'

Parameter properties

Type:String
Default value:None
Accepted values:NoRootSquash, RootSquash, AllSquash
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-StorageAccount

Storage account object

Parameter properties

Type:PSStorageAccount
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

AccountObject
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:True
Value from remaining arguments:False
AccountObjectEncryptionScope
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:True
Value from remaining arguments:False

-StorageAccountName

Storage Account Name.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AccountName

Parameter sets

AccountName
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
AccountNameEncryptionScope
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

String

PSStorageAccount

Outputs

PSContainer