Skip to content

Commit 600ab12

Browse files
committed
modify get-azurestoragecontainer fix per review comments
1 parent 716429e commit 600ab12

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/Storage/Commands.Storage/Blob/Cmdlet/GetAzureStorageContainer.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,15 @@ internal void PackCloudBlobContainerWithAcl(IEnumerable<Tuple<CloudBlobContainer
206206
return;
207207
}
208208

209-
// Write warning when user SAS credential since get container ACL will fail
210-
AzureStorageContext storageContext = this.GetCmdletStorageContext();
211-
if (storageContext != null && storageContext.StorageAccount != null && storageContext.StorageAccount.Credentials != null && storageContext.StorageAccount.Credentials.IsSAS)
209+
// Only write warning for SAS when use cmdlet alias Get-AzureStorageContainerAcl, since the cmdlets alias specified get container ACL
210+
if (this.MyInvocation.Line.ToLower().Contains("get-azurestoragecontaineracl"))
212211
{
213-
WriteWarning("Get Container ACL will fail with SAS token credentials.");
212+
// Write warning when user SAS credential since get container ACL will fail
213+
AzureStorageContext storageContext = this.GetCmdletStorageContext();
214+
if (storageContext != null && storageContext.StorageAccount != null && storageContext.StorageAccount.Credentials != null && storageContext.StorageAccount.Credentials.IsSAS)
215+
{
216+
WriteWarning("Get container permission will fail with SAS token credentials, it needs storage Account key credentials.");
217+
}
214218
}
215219

216220
IStorageBlobManagement localChannel = Channel;
@@ -238,13 +242,10 @@ internal async Task GetContainerPermission(long taskId, IStorageBlobManagement l
238242
permissions = await localChannel.GetContainerPermissionsAsync(container, accessCondition,
239243
requestOptions, OperationContext, CmdletCancellationToken).ConfigureAwait(false);
240244
}
241-
catch (StorageException e)
245+
catch (StorageException e) when (e.IsNotFoundException() || e.IsForbiddenException())
242246
{
243-
if (!e.IsNotFoundException() && !e.IsFordiddenException())
244-
{
245-
throw;
246-
}
247-
//404 Not found, or 403 Forbidden means we don't have permission to query the Permission of the specified container.
247+
// 404 Not found, or 403 Forbidden means we don't have permission to query the Permission of the specified container.
248+
// Just skip return container permission in this case.
248249
}
249250
WriteCloudContainerObject(taskId, localChannel, container, permissions, continuationToken);
250251
}

src/Storage/Commands.Storage/Common/StorageExceptionUtil.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static bool IsNotFoundException(this StorageException e)
3737
/// </summary>
3838
/// <param name="e">StorageException from storage client</param>
3939
/// <returns>Whether the storageexception is caused by Fordidden</returns>
40-
public static bool IsFordiddenException(this StorageException e)
40+
public static bool IsForbiddenException(this StorageException e)
4141
{
4242
return e.RequestInformation != null && e.RequestInformation.HttpStatusCode == 403;
4343
}

0 commit comments

Comments
 (0)