Skip to content

Commit 68a4cfb

Browse files
authored
[Storage] Refine Track2 file cmdlets migration (#26232)
* temp * temp2 * Move Track1 Blob reference in file copy cmdlet back; add context check for downloading file * remove warning * clean up * update warning message when dest context is missing; update file and directory display format * clean up code * Update help files * Update changelog * Update file and directory output display
1 parent 6a7f473 commit 68a4cfb

14 files changed

+66
-78
lines changed

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+
* Refined migration of Azure Storgae File dataplane cmdlets from 'Microsoft.Azure.Storage.File 11.2.3' to 'Azure.Storage.Files.Shares 12.16.0'
22+
- `Start-AzStorageFileCopy`
2123

2224
## Version 7.4.0
2325
* Added a warning for an upcoming breaking change for removing references to "Microsoft.Azure.Storage.File"

src/Storage/Storage.Management/help/Get-AzStorageFileContent.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ This command downloads a file that is named CurrentDataFile in the folder Contos
6262

6363
### Example 2: Downloads the files under sample file share
6464
```powershell
65-
Get-AzStorageFile -ShareName sample | Where-Object {$_.GetType().Name -eq "CloudFile"} | Get-AzStorageFileContent
65+
Get-AzStorageFile -ShareName sample | Where-Object {$_.GetType().Name -eq "AzureStorageFile"} | Get-AzStorageFileContent
6666
```
6767

6868
This example downloads the files under sample file share
@@ -282,7 +282,7 @@ Accept wildcard characters: False
282282
```
283283
284284
### -ShareClient
285-
CloudFileShare object indicated the share where the file would be downloaded.
285+
ShareClient object indicated the share where the file would be downloaded.
286286
287287
```yaml
288288
Type: Azure.Storage.Files.Shares.ShareClient

src/Storage/Storage.Management/help/New-AzStorageDirectory.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ New-AzStorageDirectory [-ShareDirectoryClient] <ShareDirectoryClient> [-Path] <S
3636

3737
## DESCRIPTION
3838
The **New-AzStorageDirectory** cmdlet creates a directory.
39-
This cmdlet returns a **CloudFileDirectory** object.
39+
This cmdlet returns a **AzureStorageFileDirectory** object.
4040

4141
## EXAMPLES
4242

src/Storage/Storage.Management/help/New-AzStorageFileSASToken.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ Accept wildcard characters: False
214214
```
215215

216216
### -ShareFileClient
217-
CloudFile instance to represent the file to get SAS token against.
217+
ShareFileClient instance to represent the file to get SAS token against.
218218

219219
```yaml
220220
Type: Azure.Storage.Files.Shares.ShareFileClient

src/Storage/Storage.Management/help/Rename-AzStorageDirectory.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Rename-AzStorageDirectory -ShareName myshare -SourcePath testdir1 -DestinationPa
4545
```
4646

4747
```output
48-
Directory: https://myaccount.file.core.windows.net/myshare
48+
AccountName: myaccount, ShareName: myshare
4949
5050
Type Length Name
5151
---- ------ ----
@@ -60,7 +60,7 @@ Get-AzStorageFile -ShareName myshare -Path testdir1 | Rename-AzStorageDirectory
6060
```
6161

6262
```output
63-
Directory: https://myaccount.file.core.windows.net/myshare
63+
AccountName: myaccount, ShareName: myshare
6464
6565
Type Length Name
6666
---- ------ ----

src/Storage/Storage.Management/help/Rename-AzStorageFile.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Rename-AzStorageFile -SourcePath testfile1 -DestinationPath testfile2 -ShareName
5353
```
5454

5555
```output
56-
Directory: https://myaccount.file.core.windows.net/myshare
56+
AccountName: myaccount, ShareName: myshare
5757
5858
Type Length Name
5959
---- ------ ----
@@ -68,7 +68,7 @@ Get-AzStorageFile -ShareName myshare -Path testfile1 | Rename-AzStorageFile -Des
6868
```
6969

7070
```output
71-
Directory: https://myaccount.file.core.windows.net/myshare
71+
AccountName: myaccount, ShareName: myshare
7272
7373
Type Length Name
7474
---- ------ ----

src/Storage/Storage.Management/help/Set-AzStorageFileContent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ Accept wildcard characters: False
271271
```
272272
273273
### -ShareDirectoryClient
274-
CloudFileDirectory object indicated the cloud directory where the file would be uploaded.
274+
ShareDirectoryClient object indicated the directory where the file would be uploaded.
275275
276276
```yaml
277277
Type: Azure.Storage.Files.Shares.ShareDirectoryClient

src/Storage/Storage.Management/help/Start-AzStorageFileCopy.md

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,24 @@ Start-AzStorageFileCopy -SrcBlobName <String> -SrcContainerName <String> -DestSh
2424

2525
### ContainerInstance
2626
```
27-
Start-AzStorageFileCopy -SrcBlobName <String> -SrcContainer <BlobContainerClient> -DestShareName <String>
28-
-DestFilePath <String> [-Context <IStorageContext>] [-DestContext <IStorageContext>] [-Force]
29-
[-ServerTimeoutPerRequest <Int32>] [-ClientTimeoutPerRequest <Int32>]
30-
[-DefaultProfile <IAzureContextContainer>] [-ConcurrentTaskCount <Int32>] [-WhatIf] [-Confirm]
31-
[<CommonParameters>]
27+
Start-AzStorageFileCopy -SrcBlobName <String> -SrcContainer <CloudBlobContainer> -DestShareName <String>
28+
-DestFilePath <String> [-DestContext <IStorageContext>] [-Force] [-ServerTimeoutPerRequest <Int32>]
29+
[-ClientTimeoutPerRequest <Int32>] [-DefaultProfile <IAzureContextContainer>] [-ConcurrentTaskCount <Int32>]
30+
[-WhatIf] [-Confirm] [<CommonParameters>]
3231
```
3332

3433
### BlobInstanceFilePath
3534
```
36-
Start-AzStorageFileCopy -SrcBlob <BlobBaseClient> -DestShareName <String> -DestFilePath <String>
37-
[-Context <IStorageContext>] [-DestContext <IStorageContext>] [-Force] [-ServerTimeoutPerRequest <Int32>]
35+
Start-AzStorageFileCopy -SrcBlob <CloudBlob> -DestShareName <String> -DestFilePath <String>
36+
[-DestContext <IStorageContext>] [-Force] [-ServerTimeoutPerRequest <Int32>]
3837
[-ClientTimeoutPerRequest <Int32>] [-DefaultProfile <IAzureContextContainer>] [-ConcurrentTaskCount <Int32>]
3938
[-WhatIf] [-Confirm] [<CommonParameters>]
4039
```
4140

4241
### BlobInstanceFileInstance
4342
```
44-
Start-AzStorageFileCopy -SrcBlob <BlobBaseClient> [-DestShareFileClient <ShareFileClient>]
45-
[-Context <IStorageContext>] [-DestContext <IStorageContext>] [-Force] [-ServerTimeoutPerRequest <Int32>]
43+
Start-AzStorageFileCopy -SrcBlob <CloudBlob> [-DestShareFileClient <ShareFileClient>]
44+
[-DestContext <IStorageContext>] [-Force] [-ServerTimeoutPerRequest <Int32>]
4645
[-ClientTimeoutPerRequest <Int32>] [-DefaultProfile <IAzureContextContainer>] [-ConcurrentTaskCount <Int32>]
4746
[-WhatIf] [-Confirm] [<CommonParameters>]
4847
```
@@ -59,24 +58,23 @@ Start-AzStorageFileCopy -SrcFilePath <String> -SrcShareName <String> -DestShareN
5958
### ShareInstance
6059
```
6160
Start-AzStorageFileCopy -SrcFilePath <String> -SrcShare <ShareClient> -DestShareName <String>
62-
-DestFilePath <String> [-Context <IStorageContext>] [-DestContext <IStorageContext>] [-Force]
63-
[-ServerTimeoutPerRequest <Int32>] [-ClientTimeoutPerRequest <Int32>]
64-
[-DefaultProfile <IAzureContextContainer>] [-ConcurrentTaskCount <Int32>] [-WhatIf] [-Confirm]
65-
[<CommonParameters>]
61+
-DestFilePath <String> [-DestContext <IStorageContext>] [-Force] [-ServerTimeoutPerRequest <Int32>]
62+
[-ClientTimeoutPerRequest <Int32>] [-DefaultProfile <IAzureContextContainer>] [-ConcurrentTaskCount <Int32>]
63+
[-WhatIf] [-Confirm] [<CommonParameters>]
6664
```
6765

6866
### FileInstanceToFilePath
6967
```
7068
Start-AzStorageFileCopy -SrcFile <ShareFileClient> -DestShareName <String> -DestFilePath <String>
71-
[-Context <IStorageContext>] [-DestContext <IStorageContext>] [-Force] [-ServerTimeoutPerRequest <Int32>]
69+
[-DestContext <IStorageContext>] [-Force] [-ServerTimeoutPerRequest <Int32>]
7270
[-ClientTimeoutPerRequest <Int32>] [-DefaultProfile <IAzureContextContainer>] [-ConcurrentTaskCount <Int32>]
7371
[-WhatIf] [-Confirm] [<CommonParameters>]
7472
```
7573

7674
### FileInstanceToFileInstance
7775
```
7876
Start-AzStorageFileCopy -SrcFile <ShareFileClient> [-DestShareFileClient <ShareFileClient>]
79-
[-Context <IStorageContext>] [-DestContext <IStorageContext>] [-Force] [-ServerTimeoutPerRequest <Int32>]
77+
[-DestContext <IStorageContext>] [-Force] [-ServerTimeoutPerRequest <Int32>]
8078
[-ClientTimeoutPerRequest <Int32>] [-DefaultProfile <IAzureContextContainer>] [-ConcurrentTaskCount <Int32>]
8179
[-WhatIf] [-Confirm] [<CommonParameters>]
8280
```
@@ -179,7 +177,7 @@ To obtain a context, use the New-AzStorageContext cmdlet.
179177
180178
```yaml
181179
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.IStorageContext
182-
Parameter Sets: ContainerName, ContainerInstance, BlobInstanceFilePath, BlobInstanceFileInstance, ShareName, ShareInstance, FileInstanceToFilePath, FileInstanceToFileInstance
180+
Parameter Sets: ContainerName, ShareName
183181
Aliases: SrcContext
184182

185183
Required: False
@@ -241,7 +239,7 @@ ShareFileClient object indicated the Dest file.
241239
```yaml
242240
Type: Azure.Storage.Files.Shares.ShareFileClient
243241
Parameter Sets: BlobInstanceFileInstance, FileInstanceToFileInstance, UriToFileInstance
244-
Aliases:
242+
Aliases: DestFile
245243

246244
Required: False
247245
Position: Named
@@ -330,9 +328,9 @@ Specifies a **CloudBlob** object.
330328
You can create a cloud blob or obtain one by using the Get-AzStorageBlob cmdlet.
331329
332330
```yaml
333-
Type: Azure.Storage.Blobs.Specialized.BlobBaseClient
331+
Type: Microsoft.Azure.Storage.Blob.CloudBlob
334332
Parameter Sets: BlobInstanceFilePath, BlobInstanceFileInstance
335-
Aliases: BlobBaseClient
333+
Aliases: ICloudBlob
336334

337335
Required: True
338336
Position: Named
@@ -361,9 +359,9 @@ Specifies a cloud blob container object.
361359
You can create cloud blob container object or use the Get-AzStorageContainer cmdlet.
362360
363361
```yaml
364-
Type: Azure.Storage.Blobs.BlobContainerClient
362+
Type: Microsoft.Azure.Storage.Blob.CloudBlobContainer
365363
Parameter Sets: ContainerInstance
366-
Aliases: BlobContainerClient
364+
Aliases:
367365

368366
Required: True
369367
Position: Named
@@ -388,8 +386,8 @@ Accept wildcard characters: False
388386
```
389387
390388
### -SrcFile
391-
Specifies a **CloudFile** object.
392-
You can create a cloud file or obtain one by using **Get-AzStorageFile**.
389+
Specifies a **ShareFileClient** object.
390+
You can create a ShareFileClient or obtain one by using **Get-AzStorageFile**.
393391
394392
```yaml
395393
Type: Azure.Storage.Files.Shares.ShareFileClient
@@ -485,7 +483,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
485483
486484
## INPUTS
487485
488-
### Azure.Storage.Blobs.Specialized.BlobBaseClient
486+
### Microsoft.Azure.Storage.Blob.CloudBlob
489487
490488
### Azure.Storage.Files.Shares.ShareFileClient
491489

src/Storage/Storage/Common/StorageCloudCmdletBase.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ internal AzureStorageContext GetCmdletStorageContext(bool outputErrorMessage = t
275275
return context;
276276
}
277277

278-
internal AzureStorageContext GetCmdletStorageContext(IStorageContext inContext, bool outputErrorMessage = true)
278+
internal AzureStorageContext GetCmdletStorageContext(IStorageContext inContext, bool outputErrorMessage = true, bool isDestContext = false)
279279
{
280280
var context = inContext as AzureStorageContext;
281281

@@ -304,8 +304,15 @@ internal AzureStorageContext GetCmdletStorageContext(IStorageContext inContext,
304304
}
305305
else
306306
{
307-
throw new InvalidOperationException("Could not get the storage context. Please pass in a storage context with \"-Context\" parameter (can be created with New-AzStorageContext cmdlet), " +
307+
if (isDestContext)
308+
{
309+
throw new InvalidOperationException("Could not get the destination storage context. Please pass in a storage context with \"-DestContext\" parameter (can be created with New-AzStorageContext cmdlet).");
310+
}
311+
else
312+
{
313+
throw new InvalidOperationException("Could not get the storage context. Please pass in a storage context with \"-Context\" parameter (can be created with New-AzStorageContext cmdlet), " +
308314
"or set the current storage context with Set-AzCurrentStorageAccount cmdlet.");
315+
}
309316
}
310317
}
311318
catch (Exception e)

src/Storage/Storage/File/Cmdlet/GetAzureStorageFileContent.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ public override void ExecuteCmdlet()
150150
string[] path = NamingUtil.ValidatePath(this.Path, true);
151151
switch (this.ParameterSetName)
152152
{
153-
case LocalConstants.FileParameterSetName:
153+
case LocalConstants.FileParameterSetName:
154+
CheckContextForObjectInput((AzureStorageContext)this.Context);
154155
fileClientToBeDownloaded = this.ShareFileClient;
155156
fileToBeDownloaded = AzureStorageFile.GetTrack1FileClient(fileClientToBeDownloaded, ((AzureStorageContext)this.Context).StorageAccount.Credentials);
156157
break;
@@ -164,11 +165,13 @@ public override void ExecuteCmdlet()
164165
break;
165166

166167
case LocalConstants.ShareParameterSetName:
168+
CheckContextForObjectInput((AzureStorageContext)this.Context);
167169
fileClientToBeDownloaded = this.ShareClient.GetRootDirectoryClient().GetFileClient(this.Path);
168170
fileToBeDownloaded = AzureStorageFile.GetTrack1FileClient(fileClientToBeDownloaded, ((AzureStorageContext)this.Context).StorageAccount.Credentials);
169171
break;
170172

171173
case LocalConstants.DirectoryParameterSetName:
174+
CheckContextForObjectInput((AzureStorageContext)this.Context);
172175
fileClientToBeDownloaded = this.ShareDirectoryClient.GetFileClient(this.Path);
173176
fileToBeDownloaded = AzureStorageFile.GetTrack1FileClient(fileClientToBeDownloaded, ((AzureStorageContext)this.Context).StorageAccount.Credentials);
174177
break;

0 commit comments

Comments
 (0)