How to start and stop a web application and database in VSO with vNext tasks - azure-devops

I've setup Continuous Integration in my project hosted at Visual Studio Online.
Among other things, I deploy my web application to a test slot and test database and I run integration tests.
However, I don't need the test slot and database to be running all the time. I would like to start them both for the integration tests to run and stop them after my integration tests are done, all automated.
I played around with the Azure PowerShell vNext task, but I couldn't figure out how to accomplish this. Any help would be appreciated. More than the actual answer, I would appreciate a link with more information, if possible.

For the web app slot, you can add AzurePowerShell step in your build defition can create two power-shell script: one start the website via Start-AzureWebsite command before the build start and another one stop the website via Stop-AzureWebsite after the testing is finished.
For the database, you cannot stop it. Refer to this question for details: How do I stop and start a SQL Azure database?

Related

Is it possible to run Desktop application in CICD?

I am automating functional test cases of a application where major part of it is Web UI but at some steps I have a desktop application in Main Frames ,which I automated using TestStack.White. I am able to run these test case in Visual Studio on my computer.
We have planned to put these automated test cases in CICD pipeline in VSTS.
Will I able to run test step where desktop application is involve in CICD pipeline?If yes do how can I do it?
Please suggest.
You can run UI test through Visual Studio Test task (check Test mix contains UI tests option).
Microsoft Hosted agents are pre-configured for UI test for both web apps and desktop apps.
For Self-hosted agent, you need to run it as an interactive process with auto-logon enabled (When configuring agents, select 'No' when prompted to run as a service)
More information: UI testing considerations

Automatically Combine/Bundle EF Migration(s)

I'm wondering if it is possible to run some automated tasks either on a Release (web deploy) action, or Branch Merge (TFS) action?
Ideally I would like to set up a process that will automatically combine EF migrations since the last release. I'm still looking into how I would automate this, but I think the first step is hooking into a suitable event.
I haven't setup a build server yet, but I'm guessing if the above isn't possible then this would be an option for attaching a custom procedure to the MSBuild task?
Alternatively, if anyone has experience in automating things like this I would be happy to hear it. I am the head of development at a web development company and I would like to facilitate our current processes by automating some of our standard procedures, and this is something we do over any over again for each development!
I appreciate your time looking at my question, thanks.
VSTS and TFS2015 both support a CI/CD process via their new build and release system. Very flexible and powerful. Check it out!
https://msdn.microsoft.com/Library/vs/alm/Release/getting-started/understand-rm
VS/WebDeploy does support deploying EF migrations with a web application:
https://msdn.microsoft.com/en-us/library/dd394698?f=255&MSPPError=-2147217396#efcfmigrations
This works fine for deploying a small application/system but when you want to deploy a larger system with many components it doesn't work as well. We create MSDeploy packages for each component of the system. For example, this is how we deploy SQL databases:
http://dotnetcatch.chief7.space/2016/02/10/deploying-a-database-project-with-msdeploy/

Azure Enable Web Deploy via automated deployment

Does anyone know of an automated way to deploy a web role to Azure with the "Enable Web Deploy" option enabled? We have an automated acceptance test process that deploys to Azure using Web Deploy to save time. But we would also like to automate the full deployment of the web role so that it could run off-hours on a less frequent basis.
We are currently using the WAPPSCmdlets module to automate full Azure deployments. However, neither this nor the newer official Azure Powershell cmdlets seem to expose a way to enable Web Deploy in new deployments.
What you'll need to do is create a startup task that does the following:
Download and install Web Deploy
Windows Azure Bootstrapper can help you to download and run the installer from a startup task.
Configure Web Deploy with PowerShell. You might want to start with this article: PowerShell scripts for automating Web Deploy setup
Running PowerShell from a startup task might seem tricky at first. If you run into trouble, take a look at this article: Azure Startup Tasks and Powershell: Lessons Learned
Keep in mind that this startup task should only run for CI deployments and not for your production deployments, so this might be something you need to take care of in your build process (you can use different Cloud projects in Visual Studio for example).

What is the best way to automate windows azure deployment?

Newbie to automated azure deployment here! I have the happy task of automating our deployment to the cloud. I have also done some reading and discovered that the 2 main tools are MSbuild and Powershell. Please could anyone tell me why i would use one over the other or indeed if there are any better ways to automate the deployment. Keeping in mind that my main concern is performance and i need this deplymrnt to be as fast as possible.
Any insight would be most welcome.
I'm a fan of using PowerShell for deployments. It's pretty quick to set up and the script can be pretty straight forward.
MSBuild can be great too. I use MSBuild from TFS Team Build to kick off a PowerShell script to do the deployment. Works like a champ.
A good starting point would be http://blogs.msdn.com/b/tomholl/archive/2011/12/06/automated-build-and-deployment-with-windows-azure-sdk-1-6.aspx. This blog does a great job of showing you how to build and deploy with Team Build.
If you don't want/need the Team Build and MSBuild part, then just look at his PowerShell script. That covers the basics of getting a deployment from your dev environment to Windows Azure.
You should use Web Deploy, it only takes about a minute to deploy a fix. See these links
http://blogs.msdn.com/b/cloud/archive/2011/04/19/enabling-web-deploy-for-windows-azure-web-roles-with-visual-studio.aspx
http://channel9.msdn.com/Blogs/funkyonex/Speed-Up-Azure-Deployments-with-the-New-Web-Deployment-Feature
At SplendidCRM, we had a similar need to automate deployments to Azure, but as our need was to service our live customers, we had to develop using C#. We have been watching Azure for many years, but it was not until they provided a DNS service did it make sense to make the move. Using the Azure Resource Manager (ARM) libraries, we were able to automate VM creation, SQL database creation and DNS name creation. In addition to the Microsoft documentation for ARM, we found it particularly useful to be able to get the Microsoft source code for the PowerShell scripts that wrap ARM. This is because the documentation does not always provide a complete set of settings.
In the end, we decided to release the Azure deployment code as part of a new Ultimate edition that combines order and customer management with software deployment.

Strategy for Automated UI testing on remote virtual machines

I'm using TeamCity for my CI builds, and I'd like to set up a second build for running automated UI tests on Windows XP and Windows 7 virtual machines.
I imagine the build working as follows:
Compile, run unit tests, etc.
Prepare MSI using WiX
Copy MSI to target test machines
Remotely execute MSI's
Copy test harness code to remote machine
Run tests
Build finishes
The automated UI tests are written using NUnit and would need to be run directly on the test virtual machine (they can't run remotely). It's important that if the tests fail, it appears in the TeamCity build log and the build fails. I'd rather not install VS or the TeamCity build agents on either of the test virtual machines.
It seems that most of this should be possible using psexec.exe. Are there any alternative (preferably open source) tools that I should look at?
takes a deep breath
We were looking into something to help us out with our automated UI tests. We use ranorex to test the UI and TeamCity/Msbuild to execute the tests.
We never found any tools to help us out (I’m constantly keeping an eye out for some so will monitor this thread) but here is what we did instead.
The CI server copies the setup files and test scripts to the Testing Host Server.
The CI server then launches a custom app on the Testing Host Server providing the name of the VM to launch.
The Test Host Server then launches the VM software, using Virtual PC.exe -singlepc -pc vhdname.vhd -launch , and waits for it to shutdown (after it’s run its tests).
The VM grabs the setup files and scripts from the network location and executes.
After the tests are run it then returns the results to a networked location and shuts itself down.
Control is returned to the custom app.
Control is returned to the CI server which determines from the results if it has passed or failed (and updates the UI so developers are made aware of the result).
Results are collection as artifacts in TeamCity and tagged in Svn.
I think that's everything. Its convoluted, however, it works. Hope someone of that helps you.
Jeff Brown of the Gallio team has been talking about a tool called Archimedes that he's planning to write to support this kind of requirement. It sounds promising, but I don't think there has been much progress on it so far.
In the mean time though, there is something in the Gallio project called VM Tool that may do what you want. It provides commands to stop, start and snapshot virtual machines, and more importantly, to copy files back and forth and execute commands.
I presume you have also considered Powershell Remoting?