Copy-AzStorageBlob
Copy a blob synchronously.
Syntax
ContainerName (Default)
Copy-AzStorageBlob
[-SrcBlob] <String>
-SrcContainer <String>
-DestContainer <String>
[-DestBlob <String>]
[-DestBlobType <String>]
[-StandardBlobTier <String>]
[-RehydratePriority <RehydratePriority>]
[-EncryptionScope <String>]
[-Context <IStorageContext>]
[-DestContext <IStorageContext>]
[-Force]
[-AsJob]
[-TagCondition <String>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
BlobInstance
Copy-AzStorageBlob
-DestContainer <String>
[-BlobBaseClient <BlobBaseClient>]
[-DestBlob <String>]
[-DestBlobType <String>]
[-StandardBlobTier <String>]
[-RehydratePriority <RehydratePriority>]
[-EncryptionScope <String>]
[-Context <IStorageContext>]
[-DestContext <IStorageContext>]
[-Force]
[-AsJob]
[-TagCondition <String>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
UriPipeline
Copy-AzStorageBlob
-AbsoluteUri <String>
-DestContainer <String>
-DestBlob <String>
[-DestBlobType <String>]
[-StandardBlobTier <String>]
[-RehydratePriority <RehydratePriority>]
[-EncryptionScope <String>]
[-Context <IStorageContext>]
[-DestContext <IStorageContext>]
[-Force]
[-AsJob]
[-TagCondition <String>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The Copy-AzStorageBlob cmdlet copies a blob synchronously, currently only support block blob.
Examples
Example 1: Copy a named blob to another
$destBlob = Copy-AzStorageBlob -SrcContainer "sourcecontainername" -SrcBlob "srcblobname" -DestContainer "destcontainername" -DestBlob "destblobname"
This command copies a blob from source container to the destination container with a new blob name.
Example 2: Copy blob from a blob object
$srcBlob = Get-AzStorageBlob -Container $containerName -Blob $blobName -Context $ctx
$destBlob = $srcBlob | Copy-AzStorageBlob -DestContainer "destcontainername" -DestBlob "destblobname"
This command copies a blob from source blob object to the destination container with a new blob name.
Example 3: Copy blob from a blob Uri
$srcBlobUri = New-AzStorageBlobSASToken -Container $srcContainerName -Blob $srcBlobName -Permission rt -ExpiryTime (Get-Date).AddDays(7) -FullUri
$destBlob = Copy-AzStorageBlob -AbsoluteUri $srcBlobUri -DestContainer "destcontainername" -DestBlob "destblobname"
The first command creates a blob Uri of the source blob, with sas token of permission "rt". The second command copies from source blob Uri to the destination blob.
Example 4: Update a block blob encryption scope
$blob = Copy-AzStorageBlob -SrcContainer $containerName -SrcBlob $blobname -DestContainer $containername -EncryptionScope $newScopeName -Force
This command update a block blob encryption scope by copy it to itself with a new encryption scope.
Example 5: Copy a blob to a new append blob
$srcBlob = Get-AzStorageBlob -Container $containerName -Blob $blobName -Context $ctx
$destBlob = Copy-AzStorageBlob -SrcContainer "sourcecontainername" -SrcBlob "srcblobname" -DestContainer "destcontainername" -DestBlob "destblobname" -DestBlobType "Append" -DestContext $destCtx
Parameters
-AbsoluteUri
Source blob uri
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: SrcUri, SourceUri
Parameter sets
UriPipeline
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-AsJob
Run cmdlet in the background
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
-BlobBaseClient
BlobBaseClient Object
Parameter properties
Type: BlobBaseClient
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
BlobInstance
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
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
-Context
Source Azure Storage Context Object
Parameter properties
Type: IStorageContext
Default value: None
Supports wildcards: False
DontShow: False
Aliases: SrcContext, SourceContext
Parameter sets
ContainerName
Position: Named
Mandatory: False
Value from pipeline: True
Value from pipeline by property name: True
Value from remaining arguments: False
BlobInstance
Position: Named
Mandatory: False
Value from pipeline: True
Value from pipeline by property name: True
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: 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
-DestBlob
Destination blob name
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: DestinationBlob
Parameter sets
ContainerName
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
BlobInstance
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-DestBlobType
Destination blob type
Parameter properties
Type: String
Default value: None
Accepted values: Block, Page, Append
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
-DestContainer
Destination container name
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: DestinationContainer
Parameter sets
(All)
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-DestContext
Destination Storage context object
Parameter properties
Type: IStorageContext
Default value: None
Supports wildcards: False
DontShow: False
Aliases: DestinationContext
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-EncryptionScope
Encryption scope to be used when making requests to the dest blob.
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
-Force
Force to overwrite the existing blob or file
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
-RehydratePriority
Block Blob RehydratePriority.
Indicates the priority with which to rehydrate an archived blob.
Valid values are High/Standard.
Parameter properties
Type: RehydratePriority
Default value: None
Accepted values: Standard, High
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
-SrcBlob
Blob name
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: SourceBlob
Parameter sets
ContainerName
Position: 0
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-SrcContainer
Source Container name
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: SourceContainer
Parameter sets
ContainerName
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-StandardBlobTier
Block Blob Tier, valid values are Hot/Cool/Archive/Cold.
See detail in https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-storage-tiers
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
-TagCondition
Optional Tag expression statement to check match condition. The blob request will fail when the blob tags does not match the given expression.See details in https://learn.microsoft.com/en-us/rest/api/storageservices/specifying-conditional-headers-for-blob-service-operations#tags-conditional-operations .
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
-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 .
Outputs