We use Azure DevOps with a hosted VS2017 build agent. We would like to use the the new Az PowerShell module. However, the VS2017 hosted build agent has AzureRM installed on it. The documentation states You should not install Az side-by-side with AzureRM. Remove all AzureRM modules before installing Az. and this indeed is necessary because the two conflict. There is also no Az PowerShell build task.
So the question is, how do I use the Azure Az PowerShell module from an Azure DevOps hosted VS2017 build agent?
I suppose the answer is - you dont (for the time being). Because you wont have permissions to remove the azure powershell module. Ok, apparently you can do that.
Another way to make it work, use a docker container as a build agent (inside hosted agent). That can have Az module, obviously.
They cannot be installed side by side, however one can be installed in PowerShell (non core), and the other in PowerShell Core.
From the comments in the docs you specified:
Question: The document says not to install the modules side-by-side but is there any reason that we cannot run AzureRM in PowerShell 5.1 and AZ in PowerShell Core on the same machine?
Answer: No, no reason at all. In fact we are thinking of suggesting this as an advanced scenario for those with a substantial investment in AzureRM scripts
Related
I would like to turn ON/OFF HTTPS Only of my website during the pipeline execution.
Set-AzWebApp -ResourceGroupName $(ResourceGroupName) -Name $(WebAppName) -HttpsOnly $flase
I am using private windows agent.
I am getting following issue
I have Az installed on my server.
Could you please help me?
To use Azure ClI task you need to follow below prerequisites
A Microsoft Azure subscription
Azure Resource Manager service connection to your Azure account
Microsoft hosted agents have Azure CLI pre-installed. However if you are using private agents, install Azure CLI on the
computer(s) that run the build and release agent. If an agent is
already running on the machine on which the Azure CLI is installed,
restart the agent to ensure all the relevant stage variables are
updated.
According to your error log, seems Azure CLI is either not installed properly or detected by Azure DevOps.
Please make sure you have restarted the build agent to ensure all the relevant stage variables are updated.
Besides, you could also try to use Azure CLI on the private agent directly check if you are able to use above Azure command to turn off https. This will also narrow down your issue.
I have a web project and Azure cloud service deployment project. I am currently deploying to Azure cloud service manually by creating package and updating the package in Azure portal. I wanted to automate this process using PowerShell script. I found a blog which list out the steps, but it is very old. Also, I am not able to use exec msbuild command that is mentioned in this article. Can you help me how to following command? I am not able to execute this from powershell window.
exec { msbuild /p:Configuration=Release /p:DebugType=None /p:Platform=AnyCpu /p:OutputPath= /p:TargetProfile=Cloud /t:publish /verbosity:quiet }
https://www.kenneth-truyers.net/2014/02/06/deploying-cloud-services-to-azure-with-powershell/
Are you using azure devops? If yes, and automating the deployment of your website to cloud is the problem then consider using pipelines? I hope I understood your question correctly!
I am wondering if there is an easy way to incorporate an extra tool to one of the default Microsoft hosted agent pools (specifically VS2017).
Basically, I want to add some of the extra ARM powershell modules that are not installed by default as only the core set of modules are installed; i.e. I am looking to leverage some of the extra modules such as AAD as part of the deplyment pipeline, e.g. to create an AAD role definition.
I guess the same would be true for CLI extensions if I was using the CLI instead of PS.
Essentially, I am wondering if I have to use my own agent on a self hosted agent pool (my own VMs) or if I can just add the extra modules to the microsoft hosted agent pool VMs as part of the deployment pipeline, perhaps as a task?
For PowerShell modules, you can just use Install-Module in an inline script (or at the start of your existing scripts) to ensure they're installed. That, of course, assumes the modules are in the PowerShell Gallery.
Worst case, just put the modules you need in source control and publish them as an artifact along with everything else so you can load them up.
I have a build pipeline that is working pretty well currently in Azure DevOps. As part of the pipline/build process, I create an artifact, which is published and reachable. After that, I'd like to do the following:
Create/Start Up a new VM (Windows)
Grab the now published artifact, unzip it and run the executable within
Run the integration tests
Close the VM
I've looked around the Azure documentation but cannot find much that discusses this sort of solution. Please help!
There is nothing built-in (like a readymade task create a vm), so you can use any way to create a VM in Azure. Azure powershell, Azure Cli, ARM Templates, SDK calls. whatever works for you.
You would need to open ssh\winrm to talk to that vm to deploy stuff to it. thats about it. You can find lots of examples on how to create a VM online. VSTS got tasks for Azure Powershell\Cli\ARM Tempaltes so you dont need to handle auth.
You can create a VM using ARM templates with the task 'Azure Resource Group Deployment'
With a separate task 'Powershell on target machine' you can run a powershell script on the target VM, if you put the downloading, unzipping and running of this exe in this script you should be able to perform the tasks you need.
You could also look into the 'invoke-azurermvmruncommand' powershell command, this allows you to run a powershell script in the vm. https://learn.microsoft.com/en-us/powershell/module/azurerm.compute/invoke-azurermvmruncommand?view=azurermps-6.11.0
I created a Azure VM (windows sever 2016) using azure portal. It has .net 4.6.2 installed on it. Now I want to roll out latest available .net framework (4.7/ 4.7.1) on it. One option is to download required framework and install it on the VM. I am sure there should be some other better way to roll out .net framework on Azure VMs using Azure portal or ARM template. Please help me with the option available for the same.
Like the other answer says, you could use Azure Powershell DSC extensión, but there other ways to achieve that.
Usually you dont want the latest versión of the specific app\framework. You want the versión you've tested your app\code against (so its pretty static). You could créate a VM, install all the stuff you need and capture it. You will get an image and from that image you can deploy copies of the VM. That process can be automated with packer (so you dont have to build\recapture manually when\if you want to update something).
Another options is using Azure VM Script Extensión, which is a lot easier than diving into Powershell DSC.
Also, sometimes you could find an image in the gallery that corresponds to your needs (but I doubt that it is the case this time).
There is not currently a way in the Azure portal to deploy/upgrade .NET Framework in a VM. If this was something you were going to be doing a bunch I think you should use PowerShell Desired State Configuration (to install/update .NET Framework) in an Azure Resource Manager (ARM Template). This is a good walk through for what that process would look like.
If you use Run Command from the Azure Portal to run Start-Process you can get it to run a script from storage to install .net framework.