VSTS Agent Check if VM Already in Release Environment - azure-devops

I'm trying to use Powershell DSC to provision virtual machines in Azure and use Azure DevOps to manage the actually code deployment onto the virtual machines. The DSC script is setup to install IIS, asp.net core hosting, setup the sites in IIS, but not actually deploy any application code. The last step in the DSC is to add the virtual machine to azure devops. I went into the Environments tab in devops and copied the powershell script provided, parameterized my PAT so it could be passed into the configuration script, and executed. However, when the script runs a second time, it gives an error because the a resource already exists with the same name in that environment. I could not find a way to check if the VM was already registered as an environment resource in devops using the vsts agent config. I'm considering using the --replace flag, but I don't know if that will lose my deployment history or has any other consequences.
Is there a way to check if a Virtual Machine is already registered as a resource in an Azure DevOps environment.

Related

Publishing remote test results to my Azure DevOps pipeline

I have a nodejs web application that I build in Azure Pipelines. I am planning to deploy the generated artifacts on a Azure VM (probably a dev test labs), as part of one of the pipeline steps.
I want to now run browser tests by pointing the browser to the hosted URL in the Azure VM. I want to use the Azure windows and linux VMs in a build pipeline to run the tests on this remote Azure VM and publish the results to the pipeline. These would be karma tests essentially running on the nodejs server.
In my current design, the test results are going to be available on the Azure VM hosting the nodejs application.
What I don't understand is how can I get these test results back to
the Azure Pipeline for publishing the same?
Is there a way I can architect this solution without having to setup my Azure VM as a
pipeline agent in Azure DevOps?
Is there a standard pattern to design such continuous test infrastructure using Azure DevOps?
Thanks
According to your description, you just want to use Microsoft host agent to access an url on your self-host agent (ignore it's Azure VM or your own physical machine, same to host agent).
It depends if that url are accessible through public internet.
The simplest solution here is deploy your build agent on that Azure VM directly. Then run build and test. You can do this through the following script and tasks:
run ng test or any command to raise your tests
publish test results with PublishTestResults task
publish code coverage results with PublishCodeCoverageResults task
Microsoft-hosted agent pool will not work for you with every scenarios. For many teams this is the simplest way to run your jobs. You can try it first and see if it works for your build or deployment. If not, you can use a self-hosted agent. Self-hosted agents give you more control for your builds, tests and deployments.
In your scenario, setup your Azure VM as a pipeline agent and run build/test on it should be the simplest and convenient solution.

Creating release pipeline to several VMs

I have multiple ASP.NET web applications which I want to release into different VMs. Manually installing a DevOps agent in every single VM seems really inefficient. Is there a way to make this process faster? Is it possible to create release pipeline that could directly push the code to the public ip of the VM?
As workaround, you can prepare scripts to register each new agent. Here you can find parameters: Self-hosted Windows agents - Unattended config.
If you deploy your web application with IIS deployment task,
You can have a try using task Manage IIS, which can create website in a remote machine.
And then you can add a Windows machine file copy task to copy the build artifacts to the website Physical path in the remote machine.
Another workaround is that you can manage IIS with powershell script. So that you can add task PowerShell on target machines to run powershell script to manage IIS website. You can refer the example scripts at this page, and this page. For more information about IIS powrshell command you can refer here

how to deploy an application to a particular ubuntu server using azure-devops?

I have my code in the azure repos.I have created the release pipeline which runs the task "npm install" and "npm run start".This will deploy my application.But I want to deploy this application to my ubuntu server 206.189.22.155 from the azure release pipeline.Is there any way I can configure the release pipeline to use my ubuntu server?
The only agent pool available for me is "Azure Pipelines" and for agent specification I used "ubuntu-16.04".Iam totally confused about how this works.
I just want my application to run on http://206.189.22.155:5000. I can run the application directly in the server, but the whole point is to run it from the release pipeline.So how do I connect the pipeline to my ubuntu server?I think my default azure uses some kind of virtual machine for deployment.
You can create a deployment group in Azure DevOps. Deployment groups in Azure pipelines make it easier to organize the servers you want to use to host your app. In Azure pipelines -> Devployment group, select “+New” button and type of target to register. Copy and run the Registration script in your Ubuntu server.
You can refer to https://learn.microsoft.com/en-us/azure/devops/pipelines/apps/cd/deploy-linuxvm-deploygroups?view=azure-devops&tabs=java-script#define-your-ci-build-pipeline and https://learn.microsoft.com/en-us/azure/devops/pipelines/release/deployment-groups/index?view=azure-devops for more detailed information
After you create the deployment group, you can choose it in your release pipeline
And after you configure you deployment group, you can deploy your app to the specific server.

Could not able to create an executable(.exe) from Azure Devops pipelines release

I am working for a WPF application, and recently I have migrated TFS to Azure DevOps and I am successfully able to create build artifacts as well, unfortunately, I could not create executable from the artifacts as Azure DevOps does not support InstallShield Package creation with it, now I decided to move the build artifacts to my local build server,again my company law doesn't allow to access my server from outside network, what should do to create executable.
The Build Agent needs to be able to connect to Azure DevOps. It's enough for it to be able to make an outgoing connection over https (443). The agent can be configured to connect through a web proxy server.
What alternatives do you have:
Use the hosted agent and install InstallShield as part of the build process. This will be slow, but it is doable. You'll need to execute this step as part of every build that tries to create the InstallShield package and requires you to do a head-less installation of InstallShield (given that they are the kings of Installers, I suppose this is doable).
Use a private agent in Azure. You can spin up any IaaS server on Azure, install Visual Studio, InstallShield and the Azure DevOps Agent on it and use it as a build server. There is a set of standard images file available which you can use as a basis.

How to add non azure vm into VSTS Deployment groups

As we know we can add azure vm as a machine into our VSTS deployment group using the PowerShell script which VSTS provides. Based on that we can create new release definition and add our machine into pipeline.
Question is there any way to add non azure vm into VSTS deployment group?
The script that is provided is agnostic to cloud providers and can be used on any machine with powershell and internet connectivity.