Az / AzureRM /旧版Azure Powershell冲突

时间:2019-05-30 14:40:12

标签: azure powershell azure-rm az

我正在尝试从AzureRM升级到用于Powershell的新Az模块。我们仍然有“传统”服务管理API资源的多种用法,例如经典的Azure Cloud Services,而这些(据我所知)仍然需要使用旧的Azure Powershell模块。

我已经卸载了所有AzureRM模块,然后安装了新的Az模块。但是这样做似乎破坏了旧版Azure模块。看来Azure模块和AzureRM之间存在依赖关系。运行任何服务管理命令,例如“ Get-AzureService”,结果如下:

PS C:\WINDOWS\system32> Get-AzureService
Get-AzureService : Exception has been thrown by the target of an invocation.
At line:1 char:1
+ Get-AzureService
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzureService], TargetInvocationException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.HostedServices.GetAzureServiceCommand

我尝试更新到最新的Azure Powershell模块(Update-Module Azure)。这似乎也将安装AzureRM.profile。

AzureRm.profile dependency

由于该模块无法与Az模块同时安装/使用,所以我对继续操作感到困惑。

Az and AzureRM conflict

如果您还想使用新的Az模块,是否无法通过Powershell使用旧版服务管理API?

1 个答案:

答案 0 :(得分:1)

Az模块具有兼容模式,可帮助您在更新到新语法时使用现有脚本。尝试运行Enable-AzureRmAlias cmdlet启用兼容模式,然后才能在新的Az会话中运行AzureRM命令。

enter image description here

您可以从migrating existing scripts to Az

获取更多详细信息