Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.16k stars 3.78k forks source link

Azure PowerShell Module Shows Warnings About AzureRM Retirement #23000

Open agerasimchikeg opened 9 months ago

agerasimchikeg commented 9 months ago

Description

If you install both the “Azure” and the “AzureRM” modules, when using "Azure" module cmdlets you receive warnings about “AzureRM” module retirement:

'Because the Az modules have all the capabilities of AzureRM modules and more, we will retire the AzureRM modules on 29 February 2024. Learn more about the migration to Az: http://aka.ms/azpsmigrate.'

The “Azure” and “AzureRM” PowerShell modules comes with their own copies of an internal library called Microsoft.WindowsAzure.Commands.Common.dll. This library contains various infrastructure-logic and it’s this library which produce the retirement-warning. There appears to be an issue with the DLL search order when this library is loaded - when you are using the Azure module, the AzureRM-copy of this library is loaded.

Reproducing the issue:

  1. Create a new Azure Virtual Machine of type Windows Server 2022 Datacenter Azure Edition.
  2. Log on to the VM.
  3. Run the PowerShell command “Install-Module Azure” to install the Azure module.
  4. Run the PowerShell command “Install-Module AzureRM” to install the AzureRM module.
  5. Open a new PowerShell prompt and run the command Get-AzureDeployment. (This command is part of the “Azure” module)
  6. When prompted for service name, enter an arbitrary string.

Issue script & Debug output

PS C:\Windows\system32> get-azuredeployment

cmdlet Get-AzureDeployment at command pipeline position 1
Supply values for the following parameters:
(Type !? for Help.)
ServiceName: test
DEBUG: 8:38:06 AM - GetAzureDeploymentCommand begin processing with ParameterSet '__AllParameterSets'.
WARNING: Because the Az modules have all the capabilities of AzureRM modules and more, we will retire the AzureRM
modules on 29 February 2024. Learn more about the migration to Az: http://aka.ms/azpsmigrate.
get-azuredeployment : No default subscription has been designated. Use Select-AzureSubscription -Default
<subscriptionName> to set the default subscription.
At line:1 char:1
+ get-azuredeployment
+ ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzureDeployment], ApplicationException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.HostedServices.GetAzureDeploymentComma
   nd

DEBUG: AzureQoSEvent: CommandName - Get-AzureDeployment; IsSuccess - False; Duration - 00:00:00.1488013; Exception -
System.ApplicationException: No default subscription has been designated. Use Select-AzureSubscription -Default
<subscriptionName> to set the default subscription.
   at
Microsoft.Azure.Commands.Common.Authentication.Factories.ClientFactory.CreateClient[TClient](IAzureContextContainer
profile, IAzureSubscription subscription, String endpoint)
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at
Microsoft.WindowsAzure.Commands.ServiceManagement.HostedServices.GetAzureDeploymentCommand.<OnProcessRecord>b__8_0()
   at
Microsoft.WindowsAzure.Commands.Utilities.Common.ServiceManagementBaseCmdlet.ExecuteClientActionNewSM[TResult](Object
input, String operationDescription, Func`1 action, Func`3 contextFactory);
DEBUG: Finish sending metric.
DEBUG: 8:38:07 AM - GetAzureDeploymentCommand end processing.
DEBUG: 8:38:07 AM - GetAzureDeploymentCommand end processing.

Environment data

Name                           Value
----                           -----
PSVersion                      5.1.22000.2538
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22000.2538
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Module versions

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     5.8.4      AzureRM.Profile                     {Add-AzureRmEnvironment, Clear-AzureRmContext, Clear-Azure...

Error output

PS C:\Windows\system32> resolve-azurermerror
DEBUG: 8:39:57 AM - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
WARNING: Because the Az modules have all the capabilities of AzureRM modules and more, we will retire the AzureRM
modules on 29 February 2024. Learn more about the migration to Az: http://aka.ms/azpsmigrate.

   HistoryId: 5

Message        : No default subscription has been designated. Use Select-AzureSubscription -Default <subscriptionName>
                 to set the default subscription.
StackTrace     :    at Microsoft.Azure.Commands.Common.Authentication.Factories.ClientFactory.CreateClient[TClient](IAz
                 ureContextContainer profile, IAzureSubscription subscription, String endpoint)
                    at System.Lazy`1.CreateValue()
                    at System.Lazy`1.LazyInitValue()
                    at Microsoft.WindowsAzure.Commands.ServiceManagement.HostedServices.GetAzureDeploymentCommand.<OnPr
                 ocessRecord>b__8_0()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.ServiceManagementBaseCmdlet.ExecuteClientAction
                 NewSM[TResult](Object input, String operationDescription, Func`1 action, Func`3 contextFactory)
Exception      : System.ApplicationException
InvocationInfo : {Get-AzureDeployment}
Line           : get-azuredeployment -debug
Position       : At line:1 char:1
                 + get-azuredeployment -debug
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 5

   HistoryId: 4

Message        : No default subscription has been designated. Use Select-AzureSubscription -Default <subscriptionName>
                 to set the default subscription.
StackTrace     :    at Microsoft.Azure.Commands.Common.Authentication.Factories.ClientFactory.CreateClient[TClient](IAz
                 ureContextContainer profile, IAzureSubscription subscription, String endpoint)
                    at System.Lazy`1.CreateValue()
                    at System.Lazy`1.LazyInitValue()
                    at Microsoft.WindowsAzure.Commands.ServiceManagement.HostedServices.GetAzureDeploymentCommand.<OnPr
                 ocessRecord>b__8_0()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.ServiceManagementBaseCmdlet.ExecuteClientAction
                 NewSM[TResult](Object input, String operationDescription, Func`1 action, Func`3 contextFactory)
Exception      : System.ApplicationException
InvocationInfo : {Get-AzureDeployment}
Line           : get-azuredeployment
Position       : At line:1 char:1
                 + get-azuredeployment
                 + ~~~~~~~~~~~~~~~~~~~
HistoryId      : 4

   HistoryId: 1

Message        : No default subscription has been designated. Use Select-AzureSubscription -Default <subscriptionName>
                 to set the default subscription.
StackTrace     :    at Microsoft.Azure.Commands.Common.Authentication.Factories.ClientFactory.CreateClient[TClient](IAz
                 ureContextContainer profile, IAzureSubscription subscription, String endpoint)
                    at System.Lazy`1.CreateValue()
                    at System.Lazy`1.LazyInitValue()
                    at Microsoft.WindowsAzure.Commands.ServiceManagement.HostedServices.GetAzureDeploymentCommand.<OnPr
                 ocessRecord>b__8_0()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.ServiceManagementBaseCmdlet.ExecuteClientAction
                 NewSM[TResult](Object input, String operationDescription, Func`1 action, Func`3 contextFactory)
Exception      : System.ApplicationException
InvocationInfo : {Get-AzureDeployment}
Line           : get-azuredeployment
Position       : At line:1 char:1
                 + get-azuredeployment
                 + ~~~~~~~~~~~~~~~~~~~
HistoryId      : 1

DEBUG: AzureQoSEvent: CommandName - Resolve-AzureRmError; IsSuccess - True; Duration - 00:00:00.1259005; Exception - ;
DEBUG: Finish sending metric.
DEBUG: 8:39:57 AM - ResolveError end processing.
DEBUG: 8:39:57 AM - ResolveError end processing.
isra-fel commented 9 months ago

Thanks for reporting! Could you try explicitly Import-Module Azure first?

agerasimchikeg commented 9 months ago

Hello @isra-fel, unfortunately running Import-Module Azure has no change. The warning is still presented.

isra-fel commented 9 months ago

You can suppress this specific warning by setting the environment variable "SuppressAzureRmModulesRetiringWarning" to "true".

$env:SuppressAzureRmModulesRetiringWarning = 'true'

agerasimchikeg commented 9 months ago

/unresolve @isra-fel I was aware that the warnings can be suppressed, the concern is that the commands will stop functioning when the AzureRM modules have been retired if the Azure modules are in fact using an incorrect dll. I have a Microsoft support case open as well and they were not able to confirm, so they directed me to open the issue here to have it investigated.

Nickos86 commented 7 months ago

@agerasimchikeg, did you get any update on this? I've got the same issue, same service management module. When removing AzureRM locally it works as expected but I'm unable to easily remove AzureRM modules from all our VMs.

LokeshNagireddy commented 2 months ago

Hi All, @agerasimchikeg, i too got the same error,

image

did you got some update on this issue?