Deployment of multi-project MVC4 solution to Azure fails - asp.net

This is my second deployment to Azure.
First was a simple MVC4 Website with a Database, which I deployed via git. Worked like a charm.
Now I've got the following:
A solution containing three projects.
Web -> Which is the MVC4 Frontend
Models -> Contains the Models and the DB Context
Backend -> MVC4 Project for data administration
All projects are MVC4 (didn't know how to manage this better for the Models project).
In my models project I'm running the code-firt migrations.
The backend is running in the virtual directory: localhost:80/Backend
(works perfect on localhost)
Both the Web and Backend project have references to the Models Project.
Folder structure:
Solution folder contains:
Web / Models / Backend / MySolution.sln
The first time I deployed I've created a git repo in the Projects folder (cause it was a single project). Now my repo is in the solution folder.
I'm also uploading files in the Backend and move it to the other project (Web) via the following path:
Directory.GetParent(HttpContext.Current.Server.MapPath("~")).ToString() + DirSeperator + "Web" + DirSeperator + "Store" + DirSeperator;
Is this going to a problem on Azure?
So my loose question is now, how am I deploying this solution?
I've created a Website with Source control in Azure and added a SQL Database to it.
I've managed to push the solution to Azure,
but on Azure there's the messsage
Found solution ... with no deployable projects. Deploying files instead.
now.
Do you have any good tutorials for me on this problem?
Am I doing it completely wrong? (I think so)
I'm relatively new to ASP.NET and Azure, so it's a bit hard for me to understand.
Thanks,
Tobi

Followup Edit: I see now, this has more to do with configuring 2 project deploys. You will need to create deployment scripts
I'm not done doing research, but take a look at these posts:
http://blog.amitapple.com/post/38419111245/azurewebsitecustomdeploymentpart3
http://kellyhpdx.wordpress.com/2012/04/11/deploying-multiple-web-applications-to-a-single-azure-instance-and-applying-web-config-transforms-correctly/

I've managed to solve my problem.
Sorry, that I'm answering my own question - hope this doesn't offend anyone.
What I wanted to achieve is not possible with Azure Web Sites, but with Web Roles.
As seen here on CloudCover and on StructureTooBig.
So I've created a new Azure Cloud Application (provided by the Azure Tools) in Visual Studio, with a default Web Role, which is my Web Frontend project.
I've added a VirtualApplication to the Web Role with the name "backend" and the physicalDirectory set to my Backend Project path.
Then I've added a VirtualDirectory "store", which I could access from both projects for file uploads.
My WebRole looks like this now:
<WebRole name="MvcWebRole1" vmsize="ExtraSmall">
<Sites>
<Site name="Web" physicalDirectory="[projectpath]">
<VirtualApplication name="backend" physicalDirectory="[projectpath]">
</VirtualApplication>
<VirtualDirectory name="store" physicalDirectory="[projectpath]">
</VirtualDirectory>
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
</Endpoints>
<Imports>
<Import moduleName="Diagnostics" />
<Import moduleName="RemoteAccess" />
<Import moduleName="RemoteForwarder" />
</Imports>
I'm accessing (read+write) the store now via:
HttpContext.Current.Request.MapPath("/Store" + DirSeperator);
instead of
Directory.GetParent(HttpContext.Current.Server.MapPath("~")).ToString() + DirSeperator + "Web" + DirSeperator + "Store" + DirSeperator;
Which works perfectly on both projects.
So, this solution works and I've already deployed it to production!
Emerging problems:
Web Sites work with git integration, but Cloud Services won't (this is very bad for my workflow).
The deployment takes about 30-45 minutes. Holy ...
I've had to publish everything again to activate Remote Access and WebDeploy features. And I hope, WebDeploy is going to save time for deploying updates ... as everytime I'm updating now, the complete solution is replaced on server (within the mentioned time span).
Is there a way to access the data via FTP?
Ciao

Related

Web Deploy Parameters not Changing for All Servers

We have a continuous delivery process created using Jenkins, MSBuild, and Web Deploy. Things work beautifully when deploying to our development server, however, when I try to deploy a web deploy package using the *.deploy.cmd file on two newly configured servers the web.config changes defined in the parameters.xml file are not being applied. The rest of the deployment works great but I am seeing a message like this for every parameter that needs to change:
Verbose: Parameter entry 'config/1' could not be applied to '<path>\Package\PackageTmp\Web.config'. Deployment will continue with the original data. Details:
Cannot set a value on node type 'Element'.
Since the transforms for the exact same package work on deployments to one server and not to the new servers, this seems like a server configuration issue but I've gone through and checked everything against Microsoft's Web Deploy install instructions and it all looks fine. I wasn't the person who originally set up Web Deploy on the working folder so I don't know what they might have done differently. I suspect this is related to permissions but the few places I can think to check were the same on both servers.
I found other questions with this error message where it was an issue with the XPath in their parameters.xml file. I don't think this is my problem because I can deploy successfully to one of my servers but here's an example from my paramters.xml and SetParams.xml files for good measure:
parameters.xml
<parameter name="config">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="//configuration/appSettings/add[#key='config']" />
</parameter>
*.SetParameters.xml
<parameters>
<setParameter name="config" value="<add key="config" value="testing" />" />
</parameters>
Does anyone know how to fix this or what kind of additional permissions I will need on my new servers?
In retrospect this is embarrassingly obvious but it turns out that our issue was that the server support team had installed the wrong version of Web Deploy. We needed 3.5 or higher and they installed 2.10. Updating Web Deploy on the new servers resolved the issue.

Web Deploy 3.6 automatic backup not created properly when deploying from VS 2015

I am using Web Deploy 3.6 to publish a WebApp from Visual Studio to an IIS 8.5 server. I have configured automatic backup on the server side (based on this article), but when I publish my WebApp from VS2015, my backup only contain two files: archive.xml and system.xml.
If I publish the same WebApp directly from the IIS server, the backup is created as expected.
Because Web Deploy has some known Issues and limitations, I checked that there is no problem with the manifest that is automatically created and used by msdeploy to publish my WebApp.
Here is what is inside my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<sitemanifest>
<IisApp path="C:\Users\niniel\Documents\Visual Studio 2015\Projects\ContosoUniversity\ContosoUniversity\obj\Debug\Package\PackageTmp" managedRuntimeVersion="v4.0" />
<setAcl path="C:\Users\niniel\Documents\Visual Studio 2015\Projects\ContosoUniversity\ContosoUniversity\obj\Debug\Package\PackageTmp" setAclResourceType="Directory" />
<setAcl path="C:\Users\niniel\Documents\Visual Studio 2015\Projects\ContosoUniversity\ContosoUniversity\obj\Debug\Package\PackageTmp" setAclUser="anonymousAuthenticationUser" setAclResourceType="Directory" />
</sitemanifest>
I tried to publish from another computer, just to be sure that this problem is not related to my computer, I had the same problem.
Any help or thought would be appreciated :)
Just in case someone is facing the same problem, I had to give read access to the IIS_IUSRS group on the backup folder to solve my problem.
I would setup the backup by extending the WebDeploy package. This way the server doesn't have to be pre-configured for backups, its just part of the deployment.
http://www.dotnetcatch.com/2016/05/19/extending-the-webdeploy-manifest/
Side note - We stopped taking backups when we started using WebDeploy exclusively for web app deployments. Each WebDeploy package becomes the backup for the next deployment. You should evaluate taking additional backups over time and determine if this process continues to be valuable. At some point, you can hopefully stop.

Debugging ASP.NET cloud project over LAN

I've been trying to debug this ASP.NET cloud project over LAN, because we need it for testing at work. I have done plenty of research on the subject, but I simply cannot get it to work as expected. I think I have narrowed the problem down to being that, the project is a cloud service project.
If I create a new ASP.NET MVC project, without the cloud service, it works just fine, when editing the projects bindings, plus turning off the firewall of course. If I then do the same procedure, but with a cloud service project, with the asp.net mvc as the web role, I get "connection refused" when trying to access it over LAN.
Does anyone have any idea what's going on and/or how to solve it?
Bindings:
<bindings>
<binding protocol="http" bindingInformation="*:5807:localhost" />
<binding protocol="http" bindingInformation="*:5807:*" />
</bindings>
I spent almost a full day at work with exactly the same issue.
It finally started to work after I reïnstalled IIS express.
Uninstall at Programs and Features
Download the Microsoft Web Platform Installer found at link below:
http://www.microsoft.com/web/downloads/platform.aspx
search for IIS express, and install it.
After that, it worked like a charm for me. I hope it works for you as well, because I wasted way too much time on this problem...

web app & web services deployment together?

I have a question about how to deploy website and its referenced web services from Dev environment to production environment by using some easy method.
Our deploy structure is basically like Desktop->Dev Server->Production Server.
Now, I create a web service (just named MailingServices for example), I deploy it Dev Server, the URL link should like: http://192.168.3.17:90/MailingServices.asmx
and then I deploy it to production server where link is probably like http://202.70.115.114:90/MailingServices.asmx
Now I create one asp.net website to consume this mailing services.
I create this website in my desktop computer, and add a reference to MailingServices Dev link which is http://192.168.3.17:90/MailingServices.asmx, and then I check in the website to its dev environment, this stage is fine: Website Dev reference Web Services Dev.
But If deploy this website into its production server, how can I change the url link of that web services from its dev link to live link?
I currently know that when the website is deployed to production server, you can over-write the link in web.config file of website, but asp.net generates some other XML files when it add a web service reference, well I can over-write these xml files too.
However, I think this not an easy and appropriate way to complete this whole task, So I come to ask if you guys have anyone suggestion about this?
Many Thanks.
Edited
Development Environment:
Server: windows 2008
Web: ASP.NET 3.5/4.0, IIS6.0+
Source Control: VSS 2005, we do not have Automation Build & Continuous Integration
If you need to transform your web.config on deploy then I would suggest that you take a look at web.config transformations. With these transformations when you publish from inside of VS the transformations will be automatically run for you, but since it looks like you are not deploying from VS you will need to perform some work to streamline the process. Here is what you need to do conceptually:
Build your project
Prepare your site for deployment
Transform the web.config file
Publish your site
For step #3 you can use the TransformXml task that we ship with VS (when you select Web to be installed). Using this task is very easy, here is a sample project which demonstrates this.
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="TransformXml"
AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>
<Target Name="TransformWebConfig">
<TransformXml Source="some\path\to\the\source\web.config"
Transform="some\path\to\the\web.transform.config"
Destination="some\path\to\the\dest\web.config" />
</Target>
</Project>
I've got a bunch of info on using this task on my blog at http://sedodream.com/SearchView.aspx?q=TransformXml.

Website Projects in Azure Web Role

I am researching a new ASP.Net project that we would like to host in a Windows Azure Web Role.
One of the technical requirements of this project is to make use of the full pre-compilation options (non-updatable, single page assembly) of the ASP.Net Web Site project model - as opposed to the ASP.Net Web Application project model.
Is it possible to host ASP.Net Web Site projects in Azure? Best I can tell the project templates for Azure are ASP.Net Web Applications only at the moment.
Okay, I was struggling with the same problem for couple of days, here is the step-by-step guide
(1) Publish your website project to a folder (for my case is "PrecompiledWeb\WebSite1", which resides in the sub folder of my azure project)
(2) Modify your service definition(.csdef), adding a webrole
<WebRole name="WebSite1" enableNativeCodeExecution="true">
<InputEndpoints>
<InputEndpoint name="HttpIn" protocol="http" port="80" />
</InputEndpoints>
<ConfigurationSettings />
</WebRole>
(3) Run the following command(CSPack) at command prompt
cspack
CloudService1\ServiceDefinition.csdef
/role:WebRole4;WebRole4
/role:WorkerRole1;WorkerRole1\bin\Debug;WorkerRole1.dll
/role:WebSite1;PrecompiledWeb\WebSite1
/out:CloudService1.cspkg
/generateConfigurationFile:"ServiceConfig.cscfg"
(4) Basically you are almost done!
Good luck! ;)
The short answer is yes, but it isn't easy.
One of the cool things about Azure is that almost anything copy-deployable can be deployed to Azure. As such you web site project can be deployed. The difficult part is that the Visual Studio tools don't currently (and may not ever) support it. You'll need to use the CSPack command line tool to package your deployment.

Resources