Azure / Azure/azure-powershell
[Az.Storage] Set-AzCurrentStorageAccount can't set context with Oauth credential
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 54
Description
## Description
Set-AzCurrentStorageAccount can't set context with Oauth credential
## Steps to reproduce
```powershell
PS C:\Users\weiwei> $oauthCtx = New-AzStorageContext -StorageAccountName $accountName
PS C:\Users\weiwei> Set-AzCurrentStorageAccount -Context $oauthCtx
Set-AzCurrentStorageAccount : Object reference not set to an instance of an object.
At line:1 char:1
+ Set-AzCurrentStorageAccount -Context $oauthCtx
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Set-AzCurrentStorageAccount], NullReferenceException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Management.Storage.SetAzureRmCurrentStorageAccount
```
## Environment data
```
Not related
```
## Module versions
```powershell
Az.Storage 3.2.1
```
## Debug output
```
PS C:\> Set-AzCurrentStorageAccount -Context $oauthCtx -debug
DEBUG: 5:48:31 PM - SetAzureRmCurrentStorageAccount begin processing with ParameterSet 'UsingStorageContext'.
DEBUG: 5:48:32 PM - using account id '[hidden]'...
Set-AzCurrentStorageAccount : Object reference not set to an instance of an object.
At line:2 char:1
+ Set-AzCurrentStorageAccount -Context $oauthCtx -debug
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Set-AzCurrentStorageAccount], NullReferenceException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Management.Storage.SetAzureRmCurrentStorageAccount
DEBUG: 5:48:33 PM - SetAzureRmCurrentStorageAccount end processing.
```
## Error output
```
Set-AzCurrentStorageAccount : Object reference not set to an instance of an object.
At line:1 char:1
+ Set-AzCurrentStorageAccount -Context $oauthCtx
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Set-AzCurrentStorageAccount], NullReferenceException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Management.Storage.SetAzureRmCurrentStorageAccount
```
Contributor guide
Assessment
This issue has not been assessed yet.