Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: "##[warning]You're using AzureRM which will be retired soon, please schedule an update." in AzurePowerShell@5 #19843

Open
2 of 7 tasks
shurick81 opened this issue May 6, 2024 · 18 comments

Comments

@shurick81
Copy link

New issue checklist

Task name

No response

Task version

No response

Issue Description

Every time I run any AzurePowerShell@5 step, I get the following in the Pipeline output:

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Windows Server 2022

Relevant log output

Starting: Setup Azure AD App for SupportUsers
==============================================================================
Task         : Azure PowerShell
Description  : Run a PowerShell script within an Azure environment
Version      : 5.239.5
Author       : Microsoft Corporation
Help         : https://aka.ms/azurepowershelltroubleshooting
==============================================================================
Generating script.
========================== Starting Command Output ===========================
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'C:\a\_temp\ac342356-0e48-44e1-8df4-84abbf833bb7.ps1'"
Added TLS 1.2 in session.
Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.17.0\Az.Accounts.psd1 -Global
##[warning]You're using AzureRM which will be retired soon, please schedule an update.
Clear-AzContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue

Full task logs with system.debug enabled

No response

Repro steps

No response

@xcITs-Xian
Copy link

We have exactly the same issue!

In our DevOps pipeline (classic), we use an "Azure PowerShell 5.*" task that uses a service principal.
Every time this task runs, we get a warning that we are using "AzureRM".
The whole script isn't using any Azure RM commands.
Last week, this warning started to appear.

image

@jberezanski-mdg
Copy link

This actually started breaking our builds and PRs, because we use the Build Quality Checks extension to ensure no warnings are introduced by code changes. We do not use AzureRM (our scripts explicitly load recent versions of Az modules).

@taylorhutchison
Copy link

Same problem. We are getting this warning but have absolutely no AzureRM that we can tell. Is it the task itself that is using AzureRM?

@AshishDadhich4h2
Copy link

Sounds like a bug in PowerShell task itself. Couldn't find any release notes related to task: AzurePowerShell@5
According to this https://techcommunity.microsoft.com/t5/azure-tools-blog/azurerm-will-retire-by-29-february-2024/ba-p/2156169 , warning makes sense but there is no recent comment on that task link : https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/azure-powershell-v5?view=azure-pipelines

@jsandquist
Copy link

jsandquist commented May 6, 2024

I found that the tasks themselves were last updated two weeks ago to migrate from AzureRM to Az powerShell, e.g.

to list two of the Pull Requests. I assume this is the reason somehow - but haven't looked into it more than this.

@n-athan
Copy link

n-athan commented May 7, 2024

Microsoft has an option to use compatability mode with Enable-AzureRMAlias. I tried this as the first line of the inline Powershell within the AzurePowershell@5 tasks, but we still get the warning that we use the AzureRM module.
We do not use the AzureRM cmdlets in our Powershell scripts.

@dafad-dew
Copy link

Also had this one suddenly appear.
Switching it to use Powershell Core using:
pwsh: true
gets it working with no warnings.

@PKRekha
Copy link

PKRekha commented May 8, 2024

Also had this one suddenly appear. Switching it to use Powershell Core using: pwsh: true gets it working with no warnings.

Can you please provide me with more info on this, like an example of yours. I am also facing the same issue with ps5.*

@dafad-dew
Copy link

It's one of the flags you can set on the inputs of the activity.
See last line of first example here:

https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/azure-powershell-v5?view=azure-pipelines#examples

@PKRekha
Copy link

PKRekha commented May 8, 2024

It's one of the flags you can set on the inputs of the activity. See last line of first example here:

https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/azure-powershell-v5?view=azure-pipelines#examples

Thank you, it helps. But my pipeline is classic one, so I think we will have to find how to set that value?

@PKRekha
Copy link

PKRekha commented May 8, 2024

It's one of the flags you can set on the inputs of the activity. See last line of first example here:

https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/azure-powershell-v5?view=azure-pipelines#examples

got it now, I can see in advanced, Use Powershell Core check box, I will try to check that one and see if the warning goes.
I will update after I do it.
Thank you

@damu9618
Copy link

damu9618 commented May 8, 2024

Hi , I have configured my task as below
- task: AzurePowerShell@5
displayName: 'Display installed modules'
inputs:
azureSubscription:.azureServiceConnection
scriptType: inlineScript
inline: |
$VerbosePreference = "Continue"
# Enable AzureRM alias support
Enable-AzureRmAlias
Write-Host "All modules:"
Get-InstalledModule
azurePowerShellVersion: LatestVersion
pwsh: true
errorActionPreference: 'stop'
continueOnError: true
enabled: true
I have used advanced options as pwsh: true, However I could still see warning from my pipeline below
Added TLS 1.2 in session.
Import-Module -Name C:\Modules\az_11.3.1\Az.Accounts\2.17.0\Az.Accounts.psd1 -Global
##[warning]You're using AzureRM which will be retired soon, please schedule an update.

@kirill-ivlev
Copy link
Contributor

kirill-ivlev commented May 8, 2024

Thank you for raising this issue, right now our team is working on switching from AzureRM (which no longer supported from 29/02/2024) to Az.

Since we can't check user's PowerShell scripts, we are displaying such warning to notify users to double check if their scripts are also using deprecated AzureRM, it will disappear after rollout of this migration is completed.

Also, if you'd like to help our team and switch to the new Az you can add environment variable RETIRE_AZURERM_POWERSHELL_MODULE and set it to true. (This will also dismiss this warning)

@shurick81
Copy link
Author

@kirill-ivlev do you mean something like this, the last line?

    - task: AzurePowerShell@5
      displayName: 'Transform Configs and Deployment files'
      inputs:
        azureSubscription: $(PO_AzureCustSubscription)
        ScriptType: 'FilePath'
        ScriptPath: '$(System.DefaultWorkingDirectory)/Scripts/PS/cust-transform.ps1'
        errorActionPreference: 'continue'
        azurePowerShellVersion: 'LatestVersion'
      env:
        APPLICATION_INSIGHTS_CONNECTION_STRING: $(APPLICATION_INSIGHTS_CONNECTION_STRING)
        RETIRE_AZURERM_POWERSHELL_MODULE: true

@nubgamerz
Copy link

Thank you for raising this issue, right now our team is working on switching from AzureRM (which no longer supported from 29/02/2024) to Az.

Since we can't check user's PowerShell scripts, we are displaying such warning to notify users to double check if their scripts are also using deprecated AzureRM, it will disappear after rollout of this migration is completed.

Also, if you'd like to help our team and switch to the new Az you can add environment variable RETIRE_AZURERM_POWERSHELL_MODULE and set it to true. (This will also dismiss this warning)

You mentioned about this variable helping your team... does that mean by using this env var, it will provide your team access to our powershell scripts? Just want to confirm due to legal requirements.

@kirill-ivlev
Copy link
Contributor

@shurick81 yes, right

@jberezanski-mdg
Copy link

Looking at the code of VstsAzureHelpers, it seems that when RETIRE_AZURERM_POWERSHELL_MODULE is set the agent will actively try to install some Az modules and uninstall AzureRM modules from the machine. This is unacceptable in my environment, because the build server configuration (including the installed PowerShell modules) is controlled via other means and the agent should not change it (especially not as part of running a pipeline).

@m-mrks
Copy link

m-mrks commented May 14, 2024

Is there an option to only suppress the warning?

We've completed migration from AzureRM to Az; no AzureRM-modules are installed.

When we set RETIRE_AZURERM_POWERSHELL_MODULE=true, and run an AzurePowerShell@5-task (v5.239.9), the "You're using AzureRM which will be retired soon, please schedule an update."-messages is gone.

However, Uninstall-AzureRM is called on every execution.

==============================================================================
Task         : Azure PowerShell
Description  : Run a PowerShell script within an Azure environment
Version      : 5.239.9
Author       : Microsoft Corporation
Help         : https://aka.ms/azurepowershelltroubleshooting
==============================================================================
Generating script.
========================== Starting Command Output ===========================
"C:\Program Files\PowerShell\7\pwsh.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'C:\agents\Agent1\_work\_temp\8dd805fe-5887-4937-8423-4e36fc4152ce.ps1'"
Added TLS 1.2 in session.
Import-Module -Name C:\Users\<...>\Documents\PowerShell\Modules\Az.Accounts\2.12.1\Az.Accounts.psd1 -Global -PassThru -Force
Imported module 'Az.Accounts', version: 2.12.1
Update-AzConfig -DisplayBreakingChangeWarning False -AppliesTo Az
Enable-AzureRmAlias -Scope Process
Import-Module -Name C:\Users\<...>\Documents\PowerShell\Modules\Az.Resources\6.6.0\Az.Resources.psd1 -Global -PassThru -Force
Imported module 'Az.Resources', version: 6.6.0
Import-Module -Name C:\Program Files\PowerShell\Modules\Az.Storage\4.5.0\Az.Storage.psd1 -Global -PassThru -Force
Imported module 'Az.Storage', version: 4.5.0
Uninstall-AzureRm
WARNING: Running this cmdlet in PowerShell Core will only remove the modules from PowerShell Core. Please rerun this cmdlet in a PowerShell 5.1 session to remove the modules from PowerShell 5.1.
Clear-AzContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue
Clear-AzContext -Scope Process
Clear-AzConfig -DefaultSubscriptionForLogin
Connect-AzAccount

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests