添加Azure虚拟应用程序时遇到问题
我们正在尝试通过引用powershell脚本在CI/CD管道中添加azure虚拟应用程序(这是在Azure DevOps的产品中)。我已经构建了一个包含所有底层框架的容器,我已经在其上进行了测试。然而,这部分是在借用整个过程,我们似乎无法在解决方案或变通方法上取得进展。
第一次尝试:
$ArrayList = New-Object -TypeName System.Collections.ArrayList `
>> $ArrayList.Add((Add-Type -AssemblyName Microsoft.Azure.Management.WebSites.Models.VirtualApplication("/Customer", "si
te\wwwroot\Customer")))
Error:
Add-Type : A positional parameter cannot be found that accepts argument 'System.Object[]'.
At line:2 char:17
+ ... ayList.Add((Add-Type -AssemblyName Microsoft.Azure.Management.WebSite ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Add-Type], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.AddTypeCommand
$ArrayList.Add((Add-Type -TypeName Microsoft.Azure.Management.WebSites.Models.VirtualApplication("/Customer", "site\wwwroot\Customer")))第二个方向:
Error:
Add-Type : A parameter cannot be found that matches parameter name 'TypeName'.
At line:2 char:26
+ $ArrayList.Add((Add-Type -TypeName Microsoft.Azure.Management.WebSite ...
+ ~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Add-Type], ParameterBindingExce
ption
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.
AddTypeCommand发布于 2019-08-23 14:46:55
Add-Type cmdlet采用指定程序集中的类型,此cmdlet没有返回值。需要调用New-Object cmdlet来实例化这些类型。您可以查看official documents了解更多信息
以下脚本仅供参考:
Add-Type –AssemblyName Microsoft.Azure.Management.WebSites
$VA = New-Object -TypeName Microsoft.Azure.Management.WebSites.Models.VirtualApplication -ArgumentList ("/Customer", "si
te\wwwroot\Customer")
$ArrayList.Add($VA)由于某些原因,Add-Type cmdlet在我的powershell上不起作用。相反,我使用[Reflection.Assembly]::LoadFrom(path to assembly.dll)添加程序集。如果add-type抛出错误‘Unable to load…’,则可以使用[Reflection.Assembly]::LoadFrom()..“。
https://stackoverflow.com/questions/57614126
复制相似问题