你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Copy-AzStorageBlob

Copy a blob synchronously.

Syntax

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>]
Copy-AzStorageBlob
    [-BlobBaseClient <BlobBaseClient>]
    -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>]
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

Type:String
Aliases:SrcUri, SourceUri
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-AsJob

Run cmdlet in the background

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-BlobBaseClient

BlobBaseClient Object

Type:BlobBaseClient
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Context

Source Azure Storage Context Object

Type:IStorageContext
Aliases:SrcContext, SourceContext
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-DefaultProfile

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

Type:IAzureContextContainer
Aliases:AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DestBlob

Destination blob name

Type:String
Aliases:DestinationBlob
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-DestBlobType

Destination blob type

Type:String
Accepted values:Block, Page, Append
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DestContainer

Destination container name

Type:String
Aliases:DestinationContainer
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-DestContext

Destination Storage context object

Type:IStorageContext
Aliases:DestinationContext
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-EncryptionScope

Encryption scope to be used when making requests to the dest blob.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Force

Force to overwrite the existing blob or file

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-RehydratePriority

Block Blob RehydratePriority. Indicates the priority with which to rehydrate an archived blob. Valid values are High/Standard.

Type:RehydratePriority
Accepted values:Standard, High
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-SrcBlob

Blob name

Type:String
Aliases:SourceBlob
Position:0
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-SrcContainer

Source Container name

Type:String
Aliases:SourceContainer
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters: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

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters: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.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

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

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

BlobBaseClient

String

IStorageContext

Outputs

AzureStorageBlob