Skip to content

Commit 5821bd8

Browse files
authored
Fix issues in migrate to file track2 (#19622)
1 parent dbbe4bf commit 5821bd8

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/Storage/Storage/Common/AzureStorageFileShare.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public static ShareClient GetTrack2FileShareClient(CloudFileShare cloudFileShare
260260
else if (cloudFileShare.ServiceClient.Credentials.IsSharedKey) //Shared Key
261261
{
262262
fileShareClient = new ShareClient(cloudFileShare.SnapshotQualifiedUri,
263-
new StorageSharedKeyCredential(context.StorageAccountName, cloudFileShare.ServiceClient.Credentials.ExportBase64EncodedKey()), clientOptions);
263+
new StorageSharedKeyCredential(cloudFileShare.ServiceClient.Credentials.AccountName, cloudFileShare.ServiceClient.Credentials.ExportBase64EncodedKey()), clientOptions);
264264
}
265265
else //Anonymous
266266
{

src/Storage/Storage/File/Cmdlet/RemoveAzureStorageShare.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ public override void ExecuteCmdlet()
103103
else
104104
{
105105
share = AzureStorageFileShare.GetTrack2FileShareClient(this.Share, (AzureStorageContext)this.Context, this.ClientOptions);
106+
107+
// when only track1 object input, will miss storage context, so need to build storage context for prepare the output object.
108+
if (this.Context == null)
109+
{
110+
this.Context = GetStorageContextFromTrack1FileServiceClient(this.Share.ServiceClient, DefaultContext);
111+
}
106112
}
107113
break;
108114

src/Storage/Storage/File/Cmdlet/SetAzureStorageShareQuota.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,13 @@ public override void ExecuteCmdlet()
7171
break;
7272

7373
case Constants.ShareParameterSetName:
74-
share = AzureStorageFileShare.GetTrack2FileShareClient(this.Share, (AzureStorageContext)this.Context, this.ClientOptions);
74+
share = AzureStorageFileShare.GetTrack2FileShareClient(this.Share, (AzureStorageContext)this.Context, this.ClientOptions);
75+
76+
// when only track1 object input, will miss storage context, so need to build storage context for prepare the output object.
77+
if (this.Context == null)
78+
{
79+
this.Context = GetStorageContextFromTrack1FileServiceClient(this.Share.ServiceClient, DefaultContext);
80+
}
7581
break;
7682

7783
default:
@@ -88,7 +94,7 @@ public override void ExecuteCmdlet()
8894
shareProperties = share.GetProperties(this.CmdletCancellationToken).Value;
8995
}
9096

91-
WriteObject( new AzureStorageFileShare(share, this.Channel.StorageContext, shareProperties, ClientOptions));
97+
WriteObject( new AzureStorageFileShare(share, (AzureStorageContext)this.Context, shareProperties, ClientOptions));
9298
}
9399
}
94100
}

0 commit comments

Comments
 (0)