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

NullReferenceException: Test-AzureRmDataLakeStoreAccount

Open suprak opened this issue 8 years ago • 7 comments

Cmdlet(s)

Test-AzureRmDataLakeStoreAccount

PowerShell Version

5.1.16299.98

Module Version

5.0.0

OS Version

10.0.16299.98

Description

When running Test-AzureRmDataLakeStoreAccount without an active Azure context (as created by Login-AzureRmAccount, the cmdlet errors out with,

Test-AzureRmDataLakeStoreAccount : Object reference not set to an instance of an object.
+ ...       if (!(Test-AzureRmDataLakeStoreAccount -Name $this.DataLakeStor ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Test-AzureRmDataLakeStoreAccount], NullReferenceException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.DataLakeStore.TestAzureDataLakeStoreAccount

Debug Output

DEBUG: 8:49:56 AM - TestAzureDataLakeStoreAccount begin processing with ParameterSet '__AllParameterSets'.
Test-AzureRmDataLakeStoreAccount : Object reference not set to an instance of an object.
At line:1 char:1
+ Test-AzureRmDataLakeStoreAccount
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Test-AzureRmDataLakeStoreAccount], NullReferenceException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.DataLakeStore.TestAzureDataLakeStoreAccount

DEBUG: AzureQoSEvent: CommandName - Test-AzureRmDataLakeStoreAccount; IsSuccess - False; Duration - 00:00:00.0210942;
Exception - System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureSubscriptionExtensions.GetId(IAzureSubscription
subscription)
   at Microsoft.Azure.Commands.DataLakeStore.Models.DataLakeStoreClient..ctor(IAzureContext context)
   at Microsoft.Azure.Commands.DataLakeStore.Models.DataLakeStoreCmdletBase.get_DataLakeStoreClient()
   at Microsoft.Azure.Commands.DataLakeStore.TestAzureDataLakeStoreAccount.ExecuteCmdlet()
   at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
DEBUG: Finish sending metric.
DEBUG: 8:49:56 AM - TestAzureDataLakeStoreAccount end processing.
DEBUG: 8:49:56 AM - TestAzureDataLakeStoreAccount end processing.

Script/Steps for Reproduction

  1. Open a new PS session
  2. Run Test-AzureRmDataLakeStoreAccount

suprak avatar Jan 18 '18 16:01 suprak

@ro-joowan Hey Joo Wan, would you mind taking a look at this? It seems like if an ADLS Storage Accounts have unique names in Azure, then this cmdlet shouldn't require users to authenticate to check the existence of a storage account.

cormacpayne avatar Jan 18 '18 17:01 cormacpayne

@matt1883 What do you think about this? It seems to me that all API calls to ADLS should be authenticated.

ro-joowan avatar Jan 23 '18 20:01 ro-joowan

@cormacpayne @suprak, I confirmed with our PM @matt1883 that the user must login before utilizing any cmdlet.

ro-joowan avatar Jan 23 '18 23:01 ro-joowan

@ro-joowan , @matt1883

The issue isn't that the user has to log in.

The issue is that there is a null ref exception.

For an example of how other cmdlets handle users who are not logged in, see the below output. Notice how the error points the user to login? This is the standard behavior in most AzureRM cmdlets.

Please fix the behavior of Test-AzureRmDataLakeStoreAccount to match this.

PS C:\Users\akarpus> Get-AzureRmStorageAccount
Get-AzureRmStorageAccount : No account found in the context. Please login using Login-AzureRMAccount.
At line:1 char:1
+ Get-AzureRmStorageAccount
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzureRmStorageAccount], ArgumentException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Management.Storage.GetAzureStorageAccountCommand

suprak avatar Jan 24 '18 00:01 suprak

@suprak Thanks for the clarification :)

I believe I found the fix. The ADLS module, however, is frozen at the moment. I'll coordinate the fix in once it's resolved.

@matt1883 @cormacpayne

ro-joowan avatar Jan 24 '18 02:01 ro-joowan

@suprak I have addressed this in this PR: https://github.com/Azure/azure-powershell/pull/5396. Will update here when it's merged. Thank you.

@matt1883, FYI

ro-joowan avatar Jan 30 '18 18:01 ro-joowan

@suprak The PR has been approved. Closing the issue now.

ro-joowan avatar Feb 01 '18 02:02 ro-joowan