Open blueww opened 3 years ago
This can't be fixed now since: SetCurrentStorageAccount(this IAzureContext context, IStorageContext storageContext)
will lost the oauth credential when set the default context. This is caused by the function will convert the account to connectionstring, then set current context with connectionstring. But Oauth does NOT support connection string.
@dingmeng-xue , @erich-wang
Would you please help to fix the function SetCurrentStorageAccount(this IAzureContext context, IStorageContext storageContext)
? Then I can fix the cmdlet in storage module.
I think I just hit this while trying to set a context using a managed identity in Azure Functions as the default context.
System.NullReferenceException:
at Microsoft.Azure.Commands.Management.Storage.SetAzureRmCurrentStorageAccount.ExecuteCmdlet (Microsoft.Azure.PowerShell.Cmdlets.Storage.Management, Version=6.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions+<>c__3`1.<ExecuteSynchronouslyOrAsJob>b__3_0 (Microsoft.Azure.PowerShell.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob (Microsoft.Azure.PowerShell.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob (Microsoft.Azure.PowerShell.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord (Microsoft.Azure.PowerShell.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
@isra-fel Would you please help to look at this issue? The root cause is in the below common function. Any idea to fix it? https://github.com/Azure/azure-powershell-common/blob/a02bcdbecd649bd807ed2634b53fddc7d02d571f/src/Storage/AzureContextExtensions.cs#L43
Description
Set-AzCurrentStorageAccount can't set context with Oauth credential
Steps to reproduce
Environment data
Module versions
Debug output
Error output