我正在尝试从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。

azure - Az/AzureRM/旧版Azure Powershell冲突-LMLPHP

由于该模块不能与Az模块同时安装/使用,因此我不知该如何继续。

azure - Az/AzureRM/旧版Azure Powershell冲突-LMLPHP

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

最佳答案

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

azure - Az/AzureRM/旧版Azure Powershell冲突-LMLPHP

您可以从migrating existing scripts to Az获得更多详细信息

关于azure - Az/AzureRM/旧版Azure Powershell冲突,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56380450/

10-11 03:26