本文介绍了Az/AzureRM/旧版Azure Powershell冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to upgrade from AzureRM to the new Az module for powershell. We still have multiple usages of "legacy" service management API resources, such as classic Azure Cloud Services, and these (as far as I know) still require the use of the old Azure powershell module.

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

I've uninstalled all AzureRM modules and then installed the new Az modules. But doing this appears to break the legacy Azure module. It seems that there is a dependency between the Azure module and AzureRM. Running any service management command, such as "Get-AzureService" results in the following:

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.

I tried updating to the latest Azure powershell module (Update-Module Azure). This appears to also install AzureRM.profile.

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

Since that module can't be installed/used at the same time as the Az module, I'm at a loss as how to continue.

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

Is it the case that there is no way to use the legacy service management APIs via powershell if you also want to use the new Az module?

推荐答案

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

The Az module has a compatibility mode to help you use existing scripts while you update to the new syntax. Try to run Enable-AzureRmAlias cmdlet enables a compatibility mode before you want to run AzureRM commands in a new Az session.

您可以从将现有脚本迁移到Az

这篇关于Az/AzureRM/旧版Azure Powershell冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 19:38