Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从Azure DevOps管道加载Az.Kusto 2.0.0 PowerShell模块时出现问题_Azure_Powershell_Azure Data Explorer_Kql - Fatal编程技术网

从Azure DevOps管道加载Az.Kusto 2.0.0 PowerShell模块时出现问题

从Azure DevOps管道加载Az.Kusto 2.0.0 PowerShell模块时出现问题,azure,powershell,azure-data-explorer,kql,Azure,Powershell,Azure Data Explorer,Kql,要从Azure DevOps管道自动配置Azure Data Explorer数据库,我们使用PowerShell模块Az.Kusto。 我们用于执行KQL脚本的函数仅在最新版本的Az.Kusto中可用,因此我们在PowerShell脚本中运行以下指令,该脚本稍后将调用新的AzKustoScript: Install-Module -Name Az.Kusto -RequiredVersion "2.0.0" -Force -Scope CurrentUser -AllowC

要从Azure DevOps管道自动配置Azure Data Explorer数据库,我们使用PowerShell模块Az.Kusto。 我们用于执行KQL脚本的函数仅在最新版本的Az.Kusto中可用,因此我们在PowerShell脚本中运行以下指令,该脚本稍后将调用新的AzKustoScript:

Install-Module -Name Az.Kusto -RequiredVersion "2.0.0" -Force -Scope CurrentUser -AllowClobber
在我的开发机器上本地运行,但当我们将此脚本作为Azure DevOps管道的一部分运行时,会出现以下异常

2021-06-08T09:15:42.1278098Z $RuntimeException/   at System.Management.Automation.TypeOps.ResolveTypeName(ITypeName typeName, IScriptExtent errorPos)
2021-06-08T09:15:42.1413212Z    at System.Management.Automation.Language.Compiler.NewOutputTypeAttribute(AttributeAst ast)
2021-06-08T09:15:42.1462865Z    at System.Management.Automation.Language.Compiler.GetAttribute(AttributeAst attributeAst)
2021-06-08T09:15:42.1465059Z    at System.Management.Automation.Language.ScriptBlockAst.<System-Management-Automation-Language-IParameterMetadataProvider-GetScriptBlockAttributes>d__68.MoveNext()
2021-06-08T09:15:42.1466223Z    at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
2021-06-08T09:15:42.1485936Z    at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
2021-06-08T09:15:42.1503023Z    at System.Management.Automation.CompiledScriptBlockData.InitializeMetadata()
2021-06-08T09:15:42.1633625Z    at Microsoft.Azure.PowerShell.Cmdlets.Kusto.Runtime.PowerShell.GetScriptCmdlet.<ProcessRecord>b__16_0(FunctionInfo fi)
2021-06-08T09:15:42.1635647Z    at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
2021-06-08T09:15:42.1637257Z    at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
2021-06-08T09:15:42.1693162Z    at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
2021-06-08T09:15:42.1719336Z    at Microsoft.Azure.PowerShell.Cmdlets.Kusto.Runtime.PowerShell.GetScriptCmdlet.ProcessRecord()
2021-06-08T09:15:43.3829832Z ##[error]Unable to find type [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api202101.IOperation].
2021-06-08T09:15:43.5666125Z ##[error]PowerShell exited with code '1'.
2021-06-08T09:15:42.1278098Z$RuntimeException/at系统.管理.自动化.类型操作.解析类型名称(ITypeName类型名称,IScriptExtent errorPos)
2021-06-08T09:15:42.1413212Z at系统管理自动化语言编译器NewOutputTypeAttribute(AttributeAst)
2021-06-08T09:15:42.1462865Z at系统管理自动化语言编译器GetAttribute(AttributeEast)
2021-06-08T09:15:42.1465059Z at System.Management.Automation.Language.ScriptBlockAst.d_u68.MoveNext()
2021-06-08T09:15:42.1466223Z系统Linq缓冲区'1..ctor(IEnumerable'1源)
2021-06-08T09:15:42.1485936Z在System.Linq.Enumerable.ToArray[t源](IEnumerable`1源)
2021-06-08T09:15:42.1503023Z在System.Management.Automation.CompiledScriptBlockData.InitializeMetadata()上
2021-06-08T09:15:42.1633625Z在Microsoft.Azure.PowerShell.Cmdlets.Kusto.Runtime.PowerShell.GetScriptCmdlet.b_uu16_0(FunctionInfo-fi)
2021-06-08T09:15:42.1635647Z在System.Linq.Enumerable.WhereEnumerableInterator`1.MoveNext()
2021-06-08T09:15:42.1637257Z系统Linq缓冲区'1..ctor(IEnumerable'1源)
2021-06-08T09:15:42.1693162Z在System.Linq.Enumerable.ToArray[t源](IEnumerable`1源)
2021-06-08T09:15:42.1719336Z在Microsoft.Azure.PowerShell.cmdlet.Kusto.Runtime.PowerShell.GetScriptCmdlet.ProcessRecord()上
2021-06-08T09:15:43.3829832Z###[错误]找不到类型[Microsoft.Azure.PowerShell.cmdlet.Kusto.Models.Api202101.IOOperation]。
2021-06-08T09:15:43.5666125Z###[错误]PowerShell已退出,代码为“1”。
任何帮助或提示都将不胜感激

更新:

  • 安装前卸载Az.Kusto失败,并显示错误消息 “未删除任何模块。请验证要删除的模块的规格是否正确,以及这些模块是否存在于运行空间中。”

  • 我看到在目录C:\Modules\az_5.7.0中安装了az.Kusto的1.0.1版

  • 此外,当我在2.0.0版中安装Az.Kusto时,此版本将安装在C:\Users\VssAdministrator\Documents\WindowsPowerShell\Modules中

  • 当我使用Scope AllUsers安装Az.Kusto时,模块显示在C:\Program Files\WindowsPowerShell\Modules下

  • 当我导入模块时,通过指定所需版本或传递-Name和路径(import Module-Name“C:\Program Files\WindowsPowerShell\Modules\Az.Kusto\2.0.0\Az.Kusto.psm1”-Force-Global),我会得到相同的错误

  • 模块Az.Accounts安装在2.3.0版的目录C:\Modules\Az_5.7.0中

  • 我们在与安装模块和导入模块调用不同的PowerShell脚本中调用新AzKustoScript。这可能是个问题吗


在评论中添加另一个步骤,请尝试:

# Unload existing version and reinstall without clobber - removing the module should remove overlaps
Remove-Module Az.Kusto
Install-Module -Name Az.Kusto -RequiredVersion "2.0.0" -Force -Scope CurrentUser
Import-Module Az.Kusto
版本2.0.0中的一个更新要求Az.Accounts的版本稍有不同,因此也请检查以下内容:

RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '2.2.8'; }) 
下面是一些笨拙的powershell模块的故障排除步骤。导入模块后,将azure上获得的输出与开发人员计算机进行比较:

# Check the loaded module:
Get-Module Az.Kusto | FL Name,Version,Path,

# On your local, try finding the missing type and the dll loading it:
[Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api202101.IOperation]|fl Name,Module
您可以通过
import Module/azure/Module/path/to.dll
手动导入任何缺少的dll。或者,您可能会发现,由于整个
az.Kusto
模块抑制的某些错误,无法导入该dll


无论采用哪种方式,您都可能希望尝试联系模块创建者-版本2.0.0还不到3周,并且存在一些其他已知问题:

在新的空DevOps管道中隔离情况后,我发现了问题的根源

在安装和导入Az.Kusto之前,导致所有问题的调用在哪里:

Import-Module Az
删除后,这些调用成功

Install-Module -Name Az.Kusto -RequiredVersion "2.0.0" -Force -Scope CurrentUser
Import-Module Az.Kusto -RequiredVersion "2.0.0" -Force

从而提供对新AzKustoScript Cmdlet的访问。

确保在安装后手动导入:
导入模块Az.Kusto-RequiredVersion 2.0.0-Force
我们这样做了,但不幸的是错误保持不变。感谢您的提示!我在原始帖子中记录了结果和附加信息。