Visual Studio 2013 has a publish wizard for Cloud Service projects that packages and deploys a cloud service based on settings persisted in a .azurePubxml file.
I'm setting up automation of this process on a CI server, and want to leverage this functionality within MSBuild, but I'm unsure if it's even possible.
I have found a lot of articles that talk about shelling out to a PowerShell script and using a custom MSBuild target file to do the deploy, but that seems like a duplication of information that I'd rather not delve into.
Given that I have the Azure subscription credentials installed on the build machine, VS 2013, and Azure SDK 2.2, can I invoke the same mechanism that VS 2013 uses in the publish wizard to package and deploy my cloud service?
Currently, using MSBuild with the publish target, I can package the service into a .cspkg file, but I cannot figure out how to trigger to package/deploy based on a profile (.azurePubxml file) that defines the VS build config, and all of the Azure settings.
So, as you pointed out, the default targets will only give you a package. From there, Visual Studio is publishing things using their own infrastructure. Publishing the build from a CI server is considered something external to actual build process and rather something that is part of the deployment process.
If your CI technology has support for PowerShell then it's as easy as automating the Windows Azure PowerShell cmdlets to do your bidding. There's a nicely detailed article on how you might do this with Team Builds in TFS here on MSDN.
Related
We have an Azure Web App that we have Source Control integration setup with Visual Studio Online via the built in Azure functionality. This, of course, creates a build definition in our Visual Studio Online account. We have had this configured and it has worked just fine for deploying our website by queuing a build.
Our ultimate configuration is to actually create a Virtual Application and use the build to deploy to the Virtual Application instead of the web app site root.
So, we created the Virtual Application in the portal. See screenshot:
Our trouble comes in that we can't get the build definition to actually deploy to this virtual application. The build either fails or the files still end up in the site\wwwroot folder.
Our azure web app name is: inyoforum(staging)
We've tried numerous variations of the following MSBuild arguments:
/p:DeployIisAppPath="inyoforum__Staging/Forum"
/p:DeployIisAppPath="inyoforum__Staging\Forum"
/p:DeployIisAppPath="inyoforum(staging)/Forum"
/p:DeployIisAppPath="inyoforum(staging)\Forum"
We even tried other variations. We tried using a publish profile instead. We can get a publish from our local Visual Studio application to the virtual application, but we've been unable to do it from the build definition.
Any suggestions on other things to try?
You can create a publish profile to publish the website to virtual app and specify the profile in MSBuild Arguments. Steps like following:
Create a publish profile according to the instruction here: Deploying multiple virtual directories to a single Azure Website.
Check in the publish profile.
Create a new build definition and enter following strings in MSBuild arguments:
/p:DeployOnBuild=true /p:PublishProfile=xxxx.pubxml
Queue a new build with the definition, the web app will be deployed to virtual app.
You can also install MSDeploy Package Sync task and use it to deploy to virtual app. Please refer to this article for details: CUSTOM DEPLOY TASK TO DEPLOY VIRTUAL APPLICATIONS TO AZURE
I had this same problem and found virtual directories are not supported by MSDeploy PowerShell scripts. So I created a custom deployment task to support this use case. Give it try -
https://dotnetcatch.com/2016/03/22/vsts-release-custom-deploy-task-to-deploy-virtual-applications-to-azure/
I've got a website (basic html) and I want to deploy it using Azure Resource manager. It doesn't have a visual studio sln file and I don't want to create one.
I've found this tutorial for an angular website that does something along the lines that I am trying to do. http://www.azurefromthetrenches.com/how-to-publish-an-angularjs-website-with-azure-resource-manager-templates/
The problem I want to solve is that I have the Microsoft Azure SDK for .NET (VS 2015) 2.8.2 which allows me to add resources to my resource group project. The tutorial writes everything itself, rather than use visual studio to create the resources.
Does any one know how to do this?
I've got my application to build the website using a website.publishproj (found at the tutorial) so I have my zip file, what I am now lacking, is how to upload the zip file to azure using the already existing powershell that comes with the 2.8.2 SDK.
So far i've added the below code under the Import-Module statement:
C:\"Program Files (x86)"\MSBuild\14.0\bin\msbuild.exe 'C:\Source\website.publishproj' /T:Package /P:PackageLocation=".\dist" /P:_PackageTempDir="packagetmp"
$websitePackage = "C:\Source\dist\website.zip"
If you're ultimate goal here is the ability to simply deploy and changes to the Azure Web App, one solution is to setup automated deployment from a local Git repository into an Azure Web App. Firstly, you'd create the RG in the Azure portal then configure Continuous Deployment. You can then use something like Visual Studio Code to trigger the deployment from any code changes.
Good run through here: https://azure.microsoft.com/en-us/documentation/articles/web-sites-create-web-app-using-vscode/
Assuming your website is under source control eg. GitHub - you can use an ARM template to point at the GitHub repo, so when it creates a new website it will automatically pull the content into your newly created site. Great walkthrough here: https://azure.microsoft.com/en-us/documentation/articles/app-service-web-arm-from-github-provision/ or just the code can be found here: https://github.com/Azure/azure-quickstart-templates/tree/master/201-web-app-github-deploy.
You can use Azure CLI from non-Microsoft world to deploy eg.
azure group deployment create...
If this has helped, please mark as answered.
Currently our developers deploy our Mobile Service (.Net backend) from Visual Studio 2013 using the Publish Wizard. Occasionally this means that a developer deploys something that either wasn't committed at all or wan't pushed to the origin source control repository. We are already using Visual Studio Online Build servers to do Continuous Integration from the origin server so it would make sense to use the files it builds to do the deployment to remove this risk.
Currently the only way I can see of doing this is to do a "download drop as zip" from the Visual Studio Online build portal and then do a FTP style deployment. This means I lose the web deploy features of only uploading the changes.
I noticed there is a different build template called GitContinousDeploymentTemplate which allows you to specify a Windows Azure Deployment Environment, but this seems to only be applicable for traditional Cloud Services or Web sites.
If anyone knows a good way of doing this any help would be much appreciated.
Cheers
F
From here
Found a solution.
In the build definition's MSBuild arguments, add the following:
/p:DeployOnBuild=true /p:PublishProfile="{publish name}"
/p:AllowUntrustedCertificate=true /p:VisualStudioVersion=12.0
/p:UserName={username} /p:Password={pw}
You can obtain the value from the publishing profile that can be downloaded from the
Mobile Service dashboard on Azure managament portal.
Under Deployment, add the path to pubxml file in source control under "Path to Deployment Settings". Note: add an extra backslash at
the end of the path to escape the last "\".
One problem with this solution is that deployment happens regardless
of your tests outcome, but that could possibly be remedied by
modifying the build template. We used the
GitContinuousDeploymentTemplate template in our case.
We have built a small MVC4 application using Azure Cloud Services. It has been deployed through Visual Studio. Now we are going add a test environment where the application should be tested, before being deployed into production.
I would like to have our CI server to build, test and create a deployable package, This package could then be deployed to any environment, providing correct configurations.
But I have not found a convenient way to do this. It is easy to build a package for a specific environment, with configuration transformations for .config and .cscfg files.
Is having the CI server to build a separate package for each environment the way to go, or have I missed something?
There are ways described how the web.config could be modified when the WebRole is starting, but this feels a bit hacky, and not the way the guys at Microsoft intended when creating Cloud Services.
Using the CI server to deploy the specific configuration has been the easiest in my experience. I think using the Visual Studio "Build" section in Team Explorer is what your looking for. We use Team Foundation Service as our Continuous Integration and Continuous Delivery server. In Visual Studio we've created Production and Testing build configurations. In the Build tab we've created a Continuous Integration Build which will kick off unit tests on every checkin, and a Continuous Delivery Build That will deploy newly tested checked in code on a regular schedule. These Build Events can be set to use a specific (Production/Testing) build configuration.
Im new to Azure and wanted to create a Continuous Integration build using TFS. I created a build definition but building my Cloud App with simple website using a hosted buildserver in the build definition fails with error:
C:\a\src\myAzure\myAzure\myAzure.ccproj (70): The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Windows Azure Tools\2.0\Microsoft.WindowsAzure.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
I can however build locally, and manually Publish to Azure and it will deploy fine.
Im suspecting that the hosted buildserver of TFS does not support Azure 2.0?
Is there a way around this problem or will I have to forget the idea of using CI?
Seems to be so since the Build is a preview feature of the Team Foundation Service. There was the same thing with Azure SDK 1.8, but they updated the Build Servers in a couple of days. Hope that it will not take long this time.
UPDATE:
"No, TF Service hosted build machines do not have the new SDK 2.0 at this time. We expect all users to have Azure SDK 2.0 support post June 1st. In the meantime you will need to use an on-prem build controller with the bits you need and deploy to Azure from there."
(C) Trevor Hancock from Microsoft
http://social.msdn.microsoft.com/Forums/en-US/azuretfs/thread/2df796d5-1abb-4b89-a571-0b7a62b80d55
UPDATE 2:
I've managed to complete a successful build using TFS build servers with SDK 2.0 So I think this problem is resolved for now. In future I recommend not to do updates to new versions of Azure SDK until the TFS build servers are ready.