Set-AzStorageServiceLoggingProperty failing with No credentials provided
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.
@blueww can you take a look?
@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 ...
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
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 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.
Close the issue since answer provided. Please reopen if there is still question.