“无效:无法找到类型[azure.Response]。”在Azure PS脚本

问题描述 投票:0回答:0
返回azure ps特定的azurestoragequeue

,但其属性queueclient揭示了.NET类型

QueleClient的Azure SDK的实例。
Azure.Response<T>

到目前为止很好。但是客户的方法经常返回实例。例如,queueclient.exists()返回PS > [Azure.Storage.Queues.QueueClient] IsPublic IsSerial Name BaseType -------- -------- ---- -------- True False QueueClient System.Object ,queueclient.peekmessage()返回Azure.Response<T>等。 Azure.Response<bool>

我试图开始工作,简化和使独立的代码:
Azure.Response<Azure.Storage.Queues.Models.PeekedMessage>

错误是:

PS > [Azure.Response[bool]]
InvalidOperation: Unable to find type [Azure.Response].
PS > [Azure.Response`1]
InvalidOperation: Unable to find type [Azure.Response`1].
PS > [Azure.Response]
InvalidOperation: Unable to find type [Azure.Response].

当我检查“ call的结果”的结果时,它是公共类型的内部子类型,因此变量的键入似乎是正确的:
#require -Modules Az
using namespace Microsoft.WindowsAzure.Commands.Common.Storage.ResourceModel
using namespace Microsoft.WindowsAzure.Commands.Storage.Common

Connect-AzAccount
[AzureStorageContext]$context = New-AzStorageContext -StorageAccountName mystorage -UseConnectedAccount
[AzureStorageQueue]$queue = Get-AzStorageQueue -Context $context | Select-Object -First 1
[Azure.Response[bool]]$existsResponse = $queue.QueueClient.Exists()
Write-Output $existsResponse.Value

我认为这不仅仅是仿制药在PowerShell中有些问题,因为当我尝试从同一azure访问非类型类型时。COREsbly,即
azure.etag
,我会遇到相同的错误:

InvalidOperation: C:\Users\Palec\AppData\Local\Temp\script.ps1:8 Line | 8 | [Azure.Response[bool]]$existsResponse = $queue.QueueClient.Exists() | ~~~~~~~~~~~~~~~~~~~~~~ | Unable to find type [Azure.Response].
我甚至尝试使用附加型明确加载azure.core组件,但这无济于事。但是,它可以加载并包含正确的类型。

Azure.Response<bool>

我做错了什么?我正在使用PowerShell 7.5.0和Azure PS 13.2.0,如果有任何区别。
    

az.Storage模块在自定义汇编负载上下文中加载azure.core组件,而PowerShell则不会搜索在自定义汇编中加载类型的组件。
行为是设计的 - 应该隔离此类组件。

请参阅更多上下文。
	

types azure-powershell powershell-core
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.