Skip to content

Commit 1d43331

Browse files
authored
[Storage] Fix copy blob AsJob issue (#25142)
* Fix copy blob asjob issue * Add live test
1 parent f67aaf4 commit 1d43331

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/Storage/Storage.Management.Test/LiveTests/BlobTests.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ Invoke-LiveTestScenario -Name "Blob basics" -Description "Test blob basic operat
101101
Assert-AreEqual $copyBlobName1 $b.Name
102102
Assert-AreEqual "Hot" $b.AccessTier
103103
Assert-AreEqual 512 $b.Length
104+
$job = Copy-AzStorageBlob -SrcContainer $containerName -SrcBlob $blobName -DestContainer $containerName -DestBlob $copyBlobName1 -Context $ctx -StandardBlobTier Hot -RehydratePriority High -Force -AsJob
105+
sleep 10
106+
$bcopy = Receive-Job -Job $job
107+
Assert-AreEqual $copyBlobName1 $bcopy.Name
108+
104109
$blobSASUri = $b | New-AzStorageBlobSASToken -Permission rt -ExpiryTime 9999-01-01 -FullUri
105110
$b2 = Copy-AzStorageBlob -AbsoluteUri $blobSASUri -DestContainer $containerName -DestBlob $copyBlobName2 -Context $ctx -Force
106111
Assert-AreEqual $copyBlobName2 $b2.Name

src/Storage/Storage.Management/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Fixed sync copy blob issue with -AsJob is specified [#25105]
22+
- `Copy-AzStorageBlob`
2123
* Updated Storage.Management.Sdk to support API version 2023-05-01
2224

2325
## Version 7.0.0

src/Storage/Storage/Blob/Cmdlet/CopyAzureStorageBlob.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,15 @@ internal IStorageBlobManagement GetDestinationChannel()
236236
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
237237
public override void ExecuteCmdlet()
238238
{
239+
if (AsJob.IsPresent)
240+
{
241+
if (ParameterSetName == UriParameterSet)
242+
{
243+
skipSourceChannelInit = true;
244+
}
245+
DoBeginProcessing();
246+
}
247+
239248
IStorageBlobManagement destChannel = GetDestinationChannel();
240249
IStorageBlobManagement srcChannel = Channel;
241250

@@ -268,6 +277,11 @@ public override void ExecuteCmdlet()
268277
{
269278
copyAction();
270279
}
280+
281+
if (AsJob.IsPresent)
282+
{
283+
DoEndProcessing();
284+
}
271285
}
272286

273287
private void CopyBlobSync(IStorageBlobManagement SrcChannel, IStorageBlobManagement destChannel, string srcContainerName, string srcBlobName, string destContainerName, string destBlobName)

0 commit comments

Comments
 (0)