azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Set-AzStorageServiceLoggingProperty failing with No credentials provided

Open lagase opened this issue 7 years ago • 6 comments

I am running in to an error when attempting to enable logging using Set-AzStorageServiceLoggingProperty for Tables in a Storage V2 Account. I was able to set the same logging for Blob and Queue with no issues.

The command I am using after running New-AzStorageContext is the following:

Set-AzStorageServiceLoggingProperty -ServiceType Table -Context $storagectx -LoggingOperations "Read,Write,Delete" -RetentionDays 30

Error: Set-AzStorageServiceLoggingProperty : No credentials provided. At line:1 char:1 + Set-AzStorageServiceLoggingProperty -ServiceType Table -Context $stor ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Set-AzStorageServiceLoggingProperty], InvalidOperationException + FullyQualifiedErrorId : InvalidOperationException,Microsoft.WindowsAzure.Commands.Storage.Common.Cmdlet.SetAzureStorageServiceLoggingCommand

This seems like a bug to me but wanted to see if this is a known issue or if anyone has a potential workaround.

lagase avatar Apr 29 '19 16:04 lagase

@blueww can you take a look?

markcowl avatar Apr 29 '19 22:04 markcowl

@lagase

I can run the following command on a StorageV2 account without any error:

$storagectx = New-AzureStorageContext -StorageAccountName $accountName -StorageAccountKey $key
Set-AzStorageServiceLoggingProperty -ServiceType Table -Context $storagectx -LoggingOperations None -RetentionDays 30 

How do you run New-AzureStorageContext? Do you run it without input -StorageAccountKey? If you only input -StorageAccountName, it will generate an Oauth Stroage Context, and only Blob/Queue are supported with Oauth. Table only works with Key. If so, you need to create a stroage context with account name and key, then run Set-AzStorageServiceLoggingProperty -ServiceType Table ...

blueww avatar Apr 30 '19 02:04 blueww

I am using the context when I create the storage account

$storageAccount = New-AzStorageAccount -ResourceGroupName MyRGName -Name MyStorageAccount -Location $AzLocation -SkuName Standard_RAGRS -Kind StorageV2 -EnableHttpsTrafficOnly $True

The documentation is not clear on this difference in using the key with table. I'll give that a try and let you know if this succeeds or not. The error is a little misleading as well stating no credentials provided but I suppose its generic for a reason.

Thank you, Mike

lagase avatar Apr 30 '19 02:04 lagase

Thank you, this worked as expected now. Appreciate the information on how to make this work. I think updating the documentation to make this clearer would help others out.

lagase avatar Apr 30 '19 15:04 lagase

@lagase Please refer https://docs.microsoft.com/en-us/rest/api/storageservices/authorization-for-the-azure-storage-services for the support of each authentication.

Azure AD integration is available for the Blob and Queue services.

I will consider to add this link into New-AzStorageContext help.

blueww avatar May 05 '19 03:05 blueww

Close the issue since answer provided. Please reopen if there is still question.

zhusijia26 avatar Jun 06 '19 20:06 zhusijia26