Deploy published mvc application as Azure Web App programatically - asp.net-mvc

I have published my MVC application and now I want to deploy the same as Azure Web App.
I want my customers to open a .bat file in which they will be prompted for Azure Publish Settings and deploy the application.
I dont want to do the below.
Deploy the solution directly from Visual Studio
Use MsDeploy or MSBuild to build the solution with publish profiles like the below and publish in Azure
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe "I:\MyProject\MyProject.sln" /p:DeployOnBuild=true /p:PublishProfile=Production /p:Password=Mu50vKJfDdKfGsFvj5erC0awdxAi /p:AllowUntrustedCertificate=true /p:VisualStudioVersion=12.0
Can anyone suggest a solution ?
Thanks,
R. Venkatesan

There are several tools you can use to deploy a web app from the command line :
Azure CLI : https://azure.microsoft.com/en-us/documentation/articles/web-sites-deploy/#cli
Web Deploy Command Line : https://azure.microsoft.com/en-us/documentation/articles/web-sites-deploy/#webdeploy
I would prefer use a custom script that use Azure CLI so your customer will be asked for login to Azure instead of providing publish settings file.
Hope this helps,
Julien

Related

Deploy an Application on Server using Jenkins

I'm new to Jenkins, i've build the dotnet application in jenkins using microsft publish command now i want to move the exe of the application from local system (where jenkins is installed) to a actual server. how to do it? how can i move code from my local system to server. Can anyone please guide me.
One way is to zip the exe and manually deploy it on server i want to automate it.
I believe you're looking to:
Deploy your application to an Azure Virtual machine
And also automate the process
For #1: I would highly recommend using Visual Studio to publish your app to the Azure VM from your local machine for ad-hoc deployments, unless you have a hard dependency on using Jenkins.
For #2: There are a few ways in which you can do this. Here are some great resources to refer:
Deploy to a Windows Virtual Machine
Migrate an ASP.NET Web application to an Azure Virtual Machine
Deploy your ASP.NET app to Azure virtual machines by using Azure DevOps Starter
Here is another detailed blog that walks one through the CI/CD setup using Azure DevOps.

Azure web app publish with Visual Studio - not including all files

I have an MVC project being published to Azure from Visual Studio as a web app. In the solution I have a project set up as a "plugin" which is used by the web application and installed using Unity DI. Locally this works but when I publish to azure the plugin files aren't being deployed. This is how my solution and project structure is setup:
Solution MyProject
>nuget
>...
>Plugins
>Plugin.Widget.GoogleAnalytics
>MyProject.Web
>Properties
>References
>...
>Plugins
>bin
>Plugin.Widget.GoogleAnalytics (excluded from project but copied to this directory after project is built above)
>Views
>...
Web.config
Running locally if I delete Solution MyProject/MyProject.Web/Plugins/Plugin.Widget.GoogleAnalytics after is compiled the plugin doesn't appear. If I copy the contents of Solution MyProject/Plugins/Plugin.Widget.GoogleAnalytics/bin back into Solution MyProject/MyProject.Web/Plugins/Plugin.Widget.GoogleAnalytics, the plugin reappears.
The problem is, when I publish to my azure web app, it doesn't include Solution MyProject/MyProject.Web/Plugins/Plugin.Widget.GoogleAnalytics. If I FTP that directory up from my computer is still doesn't load it after restarting the app.
I've tried to include Solution MyProject/MyProject.Web/Plugins/Plugin.Widget.GoogleAnalytics in the project but it causes compilation problems since it's supposed to be added by DI and it also doesn't work after publish.
Is there a way to include the necessary files (not included in the project) during a publish so what works locally will work on azure? Or is there another way to go about this.
If I don't check the option on publish to Remove additional files at destination it usually throws this error when the site tries to load:
Method not found: 'Microsoft.Practices.Unity.IUnityContainer MyProject.Core.ContainerManager.GetConfiguredContainer()'
I've tried to debug that but it's very difficult since it only happens on the azure web app.
I found this question but it didn't give any information for this issues.
EDIT
I was able to get the plugin to work on azure by following these steps.
1) Run in dev environment locally in Debug mode.
2) Publish to azure as debug build.
3) FTP web application plugin directory to azure.
4) Restart azure app. It runs in azure but it's a debug build.
5) Publish from local dev environment as release build.
After this, I was able to publish as release build and check Remove additional files at destination. This removes the plugins in azure. Then I FTP'd the web application plugin directory to azure and start and stop web app and it works. Maybe I can take the debug steps out of this but this is working now.
Heinrich,
Can you please try this below step and see it works.
Make sure you set the build action to Content and they will get deployed.
Try deploying in release mode.
Hope it helps.
MV

Publish Azure Website to non-root folder from PowerShell

I'm testing my assumptions at the moment. I have my Asp.Net MVC application located at www.myapp.com/app and a third-party CMS system on www.myapp.com/.
The web-site is set up like described in this answer
At the moment I can publish both of the applications separately and manually from Visual Studio and it works fine.
However, I'm trying to publish my application from a build server where I'm using Azure Power-Shell scriplets:
PS> Publish-AzureWebsiteProject -Name myApp -Package MyWebDeployPackage.zip
However, documentation does not mention if you can publish with this scriplet to a non-root folder.
Any way I can publish an application to ~/app from a command line?
UPD: I can publish from msbuild via
msbuild .\SolutionName.sln /p:DeployOnBuild=true /p:PublishProfile=ProfileName /p:Password=passwordForAzurePublishing /p:AllowUntrustedCertificate=true
Where ProfileName is a web-deploy profile configured to deploy to sub-folder of Azure Web-Site and Password is deployment password from Azure profile.
However this is not an optimal solution: to deploy to test and to production environment, I need to build the application twice, which I'd like to avoid: if I compile views, it takes 7-10 minutes (we have 800 views). Doing this twice is a waste of time.
UPD 2: Created an issue on Azure SDK Tools repository: https://github.com/Azure/azure-sdk-tools/issues/2667
I don't think this is possible from PowerShell, but I might be mistaken. Looking at their publish code here https://github.com/Azure/azure-sdk-tools/blob/master/src/ServiceManagement/Services/Commands.Utilities/Websites/WebsitesClient.cs#L1136-L1168
and also here https://github.com/Azure/azure-sdk-tools/blob/master/src/ServiceManagement/Services/Commands.Utilities/Websites/WebsitesClient.cs#L1218-L1229
they don't have a parameter for the app name, and the code in the second link builds the site name/slot manually.
I would say open an issue here https://github.com/Azure/azure-sdk-tools/issues for this and somebody from the Azure PowerShell team should look at it.

How to deploy clickonce application (Web publish) using MSBuild command line utility

I would like to publish my WPF application (Click once deployment) into IIS using MSBuild command line utility. I could able to publish in to file system but web publish is not working
Any suggestions would be appreciated

Command-line to "deploy" ASP.NET MVC project

I am using Visual Studio Team Suites to develop a ASP.NET MVC project. I can deploy the web app to my dev machine using the "deploy" item from IS. Is there a command-line tool to do this task? What I am trying to do is to setup a continuous integration server (using TeamCity Pro), so that whenever I checkin new code, I will get a new build, deploy to a remote IIS server, and then run tests on the testing server.
Thanks,
-Yi
It looks like Microsoft have such a deployment tool. Never used it myself.
Scott Hanselman has blogged about it here
MSDeploy, Microsoft's upcoming command-line deployment tool (which will be integrated into VS2010) is currently available in Beta2.
Info:
http://learn.iis.net/page.aspx/346/web-deployment-tool/
Download (x86):
http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1602
Download (x64):
http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1603
Also, if you have disk access to the servers you want to deploy to from the CI server and don't need to install/remove things from the GAC or tweak the IIS metabase, plain old robocopy is a great option.

Resources