Az / AzureRM / Legacy Azure Powershell Conflicts

耗尽温柔 提交于 2019-12-22 07:58:52

问题


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.

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

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

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.

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?


回答1:


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.

You could get more details from migrating existing scripts to Az



来源:https://stackoverflow.com/questions/56380450/az-azurerm-legacy-azure-powershell-conflicts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!