I have a set of small scripts written i PowerShell using the Az module that perform some maintenance tasks as part of a release pipeline in Azure DevOps. One of these scripts use the Azure CLI for one of its operations so I need to authenticate with both Azure PowerShell and Azure CLI in the same devops task in my pipeline.
I know I can split up the script and run one section from an Azure CLI task and another from an Azure PowerShell task, but I was hoping to keep it all clean and together. I prefer the clarity and tooling when using Az-PowerShell, but since there is not yet parity between az-cli and az-powershell I sometimes need to use the former.
I may also be able to read env vars from an Azure CLI task and transfer them to PowerShell to do az login from there, but I was hoping there was a cleaner way to do this. Ideally an AzureCLIAndPowerShell task or something like that.
Is there some way to perform a headless az login on a Microsoft hosted agent from within a script launched by an Azure PowerShell task?
Or to be more precise: Is there a way to use both Az-Powershell and Azure-CLI in an authenticated state within the same task in an Azure DevOps Pipeline?