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

Upgrade to latest Storage dataplane SDK, storage cmdlet will fail with "method not found"

Open blueww opened this issue 6 months ago • 4 comments

Description

I recently upgrade Az.Storage to latest storage dataplane SDK release (Azure.Core still depends on 1.44.1),but most storage cmdlets not work in PSH 5 with following error. (PSH 7 works)

My code change can be found in the last commit in wastoresh/azure-powershell at stg98

    <PackageReference Include="Azure.Storage.Blobs" Version="12.25.0-beta.1" />
    <PackageReference Include="Azure.Storage.Files.DataLake" Version="12.23.0-beta.1" />
    <PackageReference Include="Azure.Storage.Files.Shares" Version="12.23.0-beta.1" />
    <PackageReference Include="Azure.Storage.Queues" Version="12.23.0-beta.1" />

The change is not for 5/19 release, but should be required in the recent future release.

Issue script & Debug output

$ctx = New-AzStorageContext -StorageAccountName $storageAccount
Get-AzStorageContainer -Context $ctx -MaxCount 10
Get-AzStorageContainer : Method not found: 'Void Azure.Core.RequestUriBuilder.AppendQuery(System.ReadOnlySpan`1<Char>, System.ReadOnlySpan`1<Char>, Boolean)'.
At line:2 char:1
+ Get-AzStorageContainer -Context $ctx1 -MaxCount 10
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzStorageContainer], MissingMethodException
    + FullyQualifiedErrorId : MissingMethodException,Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.GetAzureStorageContainerCommand

Environment data

Name                           Value                                                                                                                                                                                                         
----                           -----                                                                                                                                                                                                         
PSVersion                      5.1.26100.3624                                                                                                                                                                                                
PSEdition                      Desktop                                                                                                                                                                                                       
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                                                       
BuildVersion                   10.0.26100.3624                                                                                                                                                                                               
CLRVersion                     4.0.30319.42000                                                                                                                                                                                               
WSManStackVersion              3.0                                                                                                                                                                                                           
PSRemotingProtocolVersion      2.3                                                                                                                                                                                                           
SerializationVersion           1.1.0.1

Module versions

coming module Az.Storage

Error output


blueww avatar May 08 '25 05:05 blueww

Discussed with @isra-fel , and open this issue per his suggestion:

Can't say for sure. Possibilities are

blueww avatar May 08 '25 06:05 blueww

@blueww I can run the cmdlet without error in PS 5. Here's what I did

# In PS 7
.\tools\BuildScripts\BuildModules.ps1 -TargetModule Storage -Configuration Release

# In PS 5
ipmo .\artifacts\Release\Az.Accounts\Az.Accounts.psd1,.\artifacts\Release\Az.Storage\Az.Storage.psd1
new-azstorageaccount -ResourceGroupName yemingtemp -Name yemingsa061101 -SkuName Standard_GRS -Location eastus2
$ctx = New-AzStorageContext -StorageAccountName yemingsa061101
Get-AzStorageContainer -Context $ctx -MaxCount 10

It returned nothing without error

isra-fel avatar Jun 11 '25 05:06 isra-fel

@isra-fel

I still can repro this issue. Do you think we need a live debug session?

My repro steps:

  1. run : git reset ., git checkout ., git clean -dfx
  2. pull latest code of main branch on https://github.com/Azure/azure-powershell
  3. cherry-pick this commit https://github.com/wastoresh/azure-powershell/commit/3092760372071365b9000e172b1beac64f225f10
  4. In PS 7
.\tools\BuildScripts\BuildModules.ps1 -TargetModule Storage -Configuration Release
  1. in PS 5
ipmo .\artifacts\Release\Az.Accounts\Az.Accounts.psd1,.\artifacts\Release\Az.Storage\Az.Storage.psd1
$ctx = New-AzStorageContext -StorageAccountName $accountName
Get-AzStorageContainer -Context $ctx -MaxCount 10

Get error:

PS D:\code\PSH_Dev> Get-AzStorageContainer -Context $ctx -MaxCount 10
Get-AzStorageContainer : Method not found: 'Void 
Azure.Core.RequestUriBuilder.AppendQuery(System.ReadOnlySpan`1<Char>, System.ReadOnlySpan`1<Char>, Boolean)'.
At line:1 char:1
+ Get-AzStorageContainer -Context $ctx -MaxCount 10
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzStorageContainer], MissingMethodException
    + FullyQualifiedErrorId : MissingMethodException,Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.GetAzureSto 
   rageContainerCommand

If you still can't repro this issue, Would you please check

  1. if the correct SDK version is loaded in your PSH5 console by run following command after run "Get-AzStorageContainer".
PS D:\code\PSH_Dev> [appdomain]::currentdomain.getassemblies() | Where-Object {$_.location -like "*Azure.Storage.Blobs*"} | Format-Table fullName,Location

FullName                                                                                 Location                                                            
--------                                                                                 --------                                                            
Azure.Storage.Blobs, Version=12.25.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8 D:\code\PSH_Dev\artifacts\Release\Az.Storage\Azure.Storage.Blobs.dll
  1. The PSH version, following is mine:
PS D:\code\PSH_Dev> $PSVersionTable

Name                           Value                                                                                                                                                                                                         
----                           -----                                                                                                                                                                                                         
PSVersion                      5.1.26100.4202                                                                                                                                                                                                
PSEdition                      Desktop                                                                                                                                                                                                       
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                                                       
BuildVersion                   10.0.26100.4202                                                                                                                                                                                               
CLRVersion                     4.0.30319.42000                                                                                                                                                                                               
WSManStackVersion              3.0                                                                                                                                                                                                           
PSRemotingProtocolVersion      2.3                                                                                                                                                                                                           
SerializationVersion           1.1.0.1      

blueww avatar Jun 12 '25 02:06 blueww

BTW, Storage dataplane SDK has a new release recently, and it depends on "Azure.Core (>= 1.46.2)" https://www.nuget.org/packages/Azure.Storage.Blobs/12.26.0-beta.1#dependencies-body-tab

Could we just make PSH framework be ready to upgrade to the new SDK version?

blueww avatar Jun 12 '25 02:06 blueww