New-AzRmStorageContainer
Creates a Storage blob container
Note
This is the previous version of our documentation. Please consult the most recent version for up-to-date information.
Syntax
New-AzRmStorageContainer
[-ResourceGroupName] <String>
[-StorageAccountName] <String>
-Name <String>
[-PublicAccess <PSPublicAccess>]
[-Metadata <Hashtable>]
[-EnableImmutableStorageWithVersioning]
[-RootSquash <String>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzRmStorageContainer
[-ResourceGroupName] <String>
[-StorageAccountName] <String>
-Name <String>
-DefaultEncryptionScope <String>
-PreventEncryptionScopeOverride <Boolean>
[-PublicAccess <PSPublicAccess>]
[-Metadata <Hashtable>]
[-EnableImmutableStorageWithVersioning]
[-RootSquash <String>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzRmStorageContainer
-StorageAccount <PSStorageAccount>
-Name <String>
[-PublicAccess <PSPublicAccess>]
[-Metadata <Hashtable>]
[-EnableImmutableStorageWithVersioning]
[-RootSquash <String>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzRmStorageContainer
-StorageAccount <PSStorageAccount>
-Name <String>
-DefaultEncryptionScope <String>
-PreventEncryptionScopeOverride <Boolean>
[-PublicAccess <PSPublicAccess>]
[-Metadata <Hashtable>]
[-EnableImmutableStorageWithVersioning]
[-RootSquash <String>]
[-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
PS C:\>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
PS C:\>$accountObject = Get-AzStorageAccount -ResourceGroupName "myResourceGroup" -AccountName "myStorageAccount"
PS C:\>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
PS C:\> $c = New-AzRmStorageContainer -ResourceGroupName "myResourceGroup" -AccountName "mystorageaccount" -Name testcontainer -DefaultEncryptionScope "testscope" -PreventEncryptionScopeOverride $true
PS C:\> $c
ResourceGroupName: myResourceGroup, StorageAccountName: mystorageaccount
Name PublicAccess LastModified HasLegalHold HasImmutabilityPolicy
---- ------------ ------------ ------------ ---------------------
testcontainer False False
PS C:\> $c.DefaultEncryptionScope
testscope
PS C:\> $c.DenyEncryptionScopeOverride
True
This command creates a storage container with a defalt 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
PS C:\> $container = New-AzRmStorageContainer -ResourceGroupName "myersourcegroup" -AccountName "mystorageaccount" -Name "mycontainer" -RootSquash AllSquash
PS C:\> $container.EnableNfsV3AllSquash
True
PS C:\> $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
PS C:\> $c = New-AzRmStorageContainer -ResourceGroupName "myResourceGroup" -AccountName "mystorageaccount" -Name testcontainer -EnableImmutableStorageWithVersioning
PS C:\> $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.
Parameters
Prompts you for confirmation before running the cmdlet.
| Type: | SwitchParameter |
| Aliases: | cf |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Default the container to use specified encryption scope for all writes.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
The credentials, account, tenant, and subscription used for communication with azure.
| Type: | IAzureContextContainer |
| Aliases: | AzContext, AzureRmContext, AzureCredential |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Enable immutable Storage with versioning at the container level.
| Type: | SwitchParameter |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Container Metadata
| Type: | Hashtable |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Container Name
| Type: | String |
| Aliases: | N, ContainerName |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Block override of encryption scope from the container default.
| Type: | Boolean |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Container PublicAccess
| Type: | PSPublicAccess |
| Accepted values: | Container, Blob, None |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Resource Group Name.
| Type: | String |
| Position: | 0 |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Sets reduction of the access rights for the remote superuser. Possible values include: 'NoRootSquash', 'RootSquash', 'AllSquash'
| Type: | String |
| Accepted values: | NoRootSquash, RootSquash, AllSquash |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Storage account object
| Type: | PSStorageAccount |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Storage Account Name.
| Type: | String |
| Aliases: | AccountName |
| Position: | 1 |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Shows what would happen if the cmdlet runs. The cmdlet is not run.
| Type: | SwitchParameter |
| Aliases: | wi |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |