Azure-pipelines-tasks: Azure PowerShell - Does not support powershell Core

Created on 28 Dec 2018  路  46Comments  路  Source: microsoft/azure-pipelines-tasks

Environment

  • Server - Azure Pipelines

    • If using TFS on-premises, provide the version:

    • If using Azure Pipelines, provide the account name, team project name, build definition name/build number: Clarksons Cloud

  • Agent - Hosted

    • Windows Container

Issue Description

I want to run a powershell script created using powershell core against azure. However you do not offer a powershell core option. Is this currently something that will be worked on?

I can get around it if i bundle the modules for az and call the connect-azAccount and pass the application ID, tenant Id and application ID password. Then authenticate the powershell context myself. However id like the task to do this, like it currently does with AzureRM. As AzureRM modules are no longer going to be used and AZ modules are the new standard, when can we expect to see this in place?

Details of the modules im talking about can be found here: https://azure.microsoft.com/en-gb/blog/azure-powershell-cross-platform-az-module-replacing-azurerm/

Thanks

Release enhancement

Most helpful comment

Vote from me also to be able to run Core like the Standard PowerShell Task where you and check a box to Use PowerShell Core

All 46 comments

Also facing similar issue, additionally it appears windows agent doesn't have powershell core installed but the linux ones do.

Support for Az module is work in progress. I am adding @20shivangi and @niadak who will update this thread when the support is available.

Thanks great news, looking forward to when this is in place.

Is there any time frame for when we can expect this?

I'm guessing it's not so much Powershell Core support you're looking for @MarkDordoy, but the support for the cross-platform Az module @kmkumaran, @20shivangi and @niadak are working on?

If this isn't the case, I'll open a linked issue as we've got a problem where we want to migrate to the Az module on Windows agents but can't. Only asking for the clarification to check I won't be creating a duplicate.

We are currently working to support Az module (Cross Platform) in Azure PowerShell task. This will be available in Feb, 19. It will be a new Task version (Preview).

@bytemech , With the new task, you will be able to migrate to the Az module on Windows agents. If that is the issue you are facing, we can use this thread to track that.

Hello

My minimum requirement is core, however ideally id like both. Ideally I want the Azure PowerShell task to support PowerShell core (line the PowerShell task does) and also accept a service connection (which in my opinion should us AZ.profile)

As PowerShell core is now the latest version of PowerShell i'm writing all my scripts to use core. Im also using the az modules to interact with azure resources. I bundle the az modules in with my library and reference them directly so i dont really require them already on the agent, however having them there would still be handy.

To get my current core scripts to work i need to use a PowerShell task on a ubuntu agent (which does have pwsh.exe installed, windows based agents appear to not have). I then have to pass an SPN App ID, Tentant ID and SPN secret and handle the auth/context myself. Ideally i want the same as what happens with powershell 5.1. Where the task handles the authentication.

Please let me know if you need me to clarify more. I'm happy to take a call to go through it, if that is easier.

Thanks

@MarkDordoy , Your scenario should work with the new Cross Platform Azure PowerShell task. The new AzurePS task will be same as current PowerShell cross platform task in addition to having first class support for Azure authentication/connection.

So will this task offer the ability to set run in powershell core, like the task "Powershell" has?

Yes.

Do you have a date as to when this will be completed?

It will be completed within 2-3 weeks

Any arrival date for this - it sounds imminent?

It is done. You can try Azure PowershellV4 task and let us know.

Where? is it available to Azure DevOps Server as well?

When i add a task in Azure Devops with the name "Azure Powershell" i only see options for version 3,2 and 1. DO i need to wait for some kind of propagation?

It is started deploying to Azure DevOps accounts and already available in some accounts. We have double checked and the roll out process is still in progress. It might take 2-3 days more to reach all accounts.

This is not available in onprem Azure DevOps Server yet.

Is there a pull request associated ?

+1 looking forward to getting AZ support in the hosted agents.

Would also love to see support for new AZ module on hosted agents as well!
Thanks!

Git is showing master has AzurePowershellV4 in \Tasks\, but DevOps pipeline task still only has 1, 2 and 3 for me.

@Andrew-George-LG The new task is getting rolled out to production. Seems like it is not available for your account yet.

@Andrew-George-LG The new task is getting rolled out to production. Seems like it is not available for your account yet.

Still nothing - I'm wondering if I might be doing something incorrectly if it's appeared for other people. I've created a whole new pipeline, added the Azure Powershell task, but I still only get 3., 2. and 1.* as options... Is that the correct method?

@Andrew-George-LG The task has not been updated for some accounts. Can you share your account name so that I can tell you when it will be updated for your account ?

@20shivangi im also not seeing it in my account. My account has the name of clarksonscloud. eg clarksonscloud.visualstudio.com

@MarkDordoy I have checked your account. The version 4 of task has not reached to it. Once it is done, I will surely let you know.

@20shivangi Do you have a guess on when we can expect the new version of the task is on our account?

@andersdissing We are in the process of rolling out the task. We hope that it will be available in your account by end of this week.

@20shivangi thank you for the replay. looking forward to the new version

@andersdissing, The AzurePS V4 task is rolled out to all accounts. Please try and provide your feedback.

What about ADO Server?

@20shivangi It's there for me now - many thanks. Testing now 馃憤

@evertonmc , It will be available in AzureDevOps Server 2019 Update2 as that will be the next On-Prem release with new features. The timeline for that release is not finalized yet.

@andersdissing, The AzurePS V4 task is rolled out to all accounts. Please try and provide your feedback.

I have test the new version and it work as expected. Thank you @niadak. The only feedback I have is. The new version trigger a warning:

"##[warning]Both Az and AzureRM modules were detected on this machine. Az and AzureRM modules cannot be imported in the same session or used in the same script or runbook. If you are running PowerShell in an environment you control you can use the 'Uninstall-AzureRm' cmdlet to remove all AzureRm modules from your machine. If you are running in Azure Automation, take care that none of your runbooks import both Az and AzureRM modules. More information can be found here: https://aka.ms/azps-migration-guide"

I have a question/clarification related to this update.

This task will only run on a self-hosted agent at the moment, when you install the AZ modules.

Does anyone know of any hosted agents that support the AZ modules yet?

Hosted VS2017 agent has Az module installed and can be used to run this task.

@andersdissing, Thanks for the feedback. This is a conscious choice to install both Az and AzureRM modules in Hosted Agent as we need to support both AzurePS V3 and AzurePS V4 task. Please ignore the warning for now.

@niadak this is also working for me, however it would be great if i could specify the version of powershell to use. Eg core vs desktop.

As ive wrote scripts that use the Az module, but require version 6 or above. The standard powershell task runner supports the option to run with core. Will this be coming any time soon for the Azure Powershell task?

is it possible to get Enable-AzureRMAlias added to the runtime environment for the V4 of this task?

@MarkDordoy , We can add the PowerShell version customization as an enhancement of the task. Thanks for the feedback.

@brwilkinson , For scripts with AzureRM commands, please use V3 task if you are using Hosted agent. For private agent scenario, you can set Enable-AzureRMAlias in your script.

@niadak was trying to consider a way not to modify old scripts. Was thinking to use the global PowerShell profile, to have enable-azurermalias set on the self hosted agents, however this this task runs with -noprofile?

That way this would be backwards compatible. . . an option at the bottom of the task for a) load profile on agent b) enable azure rm alias on agent, would be ideal.

Would very much like to be able to choose to run Core on a self-hosted windows agent!

Vote from me also to be able to run Core like the Standard PowerShell Task where you and check a box to Use PowerShell Core

Is there a shorthand way to run PowerShell Core instead of Powershell? Using the task and setting a flag to use PowerShell Core is very verbose. This is what I mean by shorthand:

- script: echo Input macro = $(mySimpleVar). Env var = $MYSIMPLEVAR
  condition: in(variables['agent.os'], 'Darwin', 'Linux')
- bash: echo Input macro = $(my.dotted.var). Env var = $MY_DOTTED_VAR
- powershell: Write-Host "Input macro = $(my var with spaces). Env var = $env:MY_VAR_WITH_SPACES"

@RehanSaeed
Powershell core is not supported for windows agent in Azure PowerShell task . We will add the support as per our team priority.

Was this page helpful?
0 / 5 - 0 ratings