How to go about deployment of ASP.Net 4.5 / MVC 4 /SQL Express 2008 R2 to a Windows Azure Free Website - asp.net-mvc

I am very new to Windows Azure - have been into asp.net for about 10 years now and have been deploying applications via Database backup and restore on production and copy of final code bits from source control to the root folder on production database.
I am doing my initial reading and finding it a bit difficult to absorb the overall process of deploying an ASP.Net MVC web Application to Azure.
I have managed to have the database and the website code on Azure and it is up and running, but I can't get to terms on the following points and want to understand them better to have a regular deployment on place as versions of my app keep going up.
Database doesn't work like backup a local database and then upload .bak file and restore to the production server.
Nor can I see my website files.
Update: 04-Aug-2013
Azure Websites have an FTP option. You can see your FTP host name in respective website Dashboard. The username and password for FTP are located in the publish settings file (note: you got to pick up the FTP username and password, NOT the publish username/password. They both are different.
When I am getting ready for version 2.0 of my product, how do I get the database from the Azure SQL, upgrade it to 2.0 and put it back?
I assume the publishing wizard from Visual Studio should be able to take care of code upgrade, but how do I edit my production web.config file on the fly?
How do I take my website offline and show users my custom "offline" page when I am in the middle of the upgrade? (Stopping the website shows up the Windows Azure site not available page).

For your database backup / upgrade questions
For migration of databases to SQL Azure (or pulling them down) the SQL Database Migration Wizard has proven to be a lifesaver for me, get it here:
http://sqlazuremw.codeplex.com/
This will pull and push both data and schema for your database.
For seeing your website files
You won't be able to if you are using Windows Azure Websites.
For editing web.config on fly
You can't. BUT -- you can edit connection strings and appsettings through the 'configure' tab of your website like so:
Turning your website offline during upgrade
While you cannot specifically use the app_offline route without another deployment. One thing you could do is change your default document. This is easily done right in the same 'configure' tab for the website in the portal as I mentioned above, see here:
Hope this helps.

Related

What is needed to open up an MVC project on a remote server?

I'm new to web development so please be kind. Anyway, I'm writing a web page in visual web developer 2012 and have hit a roadblock. I've got lots more experience with writing console applications. When writing one of those and you build the application, the bin folder is populated with the files that are required to run the application, most notable the .exe . But when I build the page all I get is .cshtml files, which when opened all it does is open the code in my web browser. I tried to get an answer on another web site but all that i got was "open it up on a web server". That doesn't make any sense to me. Please help.....
You open the project locally on your workstation, as you would any other project. But when you're ready to publish the project you would send it to a web server.
Visual Web Developer (being akin to Visual Studio, no?) should have a small built-in web server of some sort which it uses when you execute your project in debug mode. (There are more details than that, but that statement alone should be true enough to get you debugging.) That's fine for ongoing development work, but not for the resulting production application.
Analogous to installing a console application on a target workstation, you would need to publish your web application to a web server. This server may coincidentally by the same workstation on which you develop the code, but that's not a requirement.
A "web server" in this case can be one of many things. Your computer (running IIS, most likely), a server hosted somewhere, a service in the cloud, etc. And "publishing" could mean any number of things as well. Uploading the files, using built-in publishing tools in the IDE, even just committing the files to source control and allowing an automated publish service to fetch them (I do this a lot in Azure web sites).
Ultimately, the way you execute a web application that's been published isn't by double-clicking on a file anywhere. The .cshtml files, as well as any other needed files (binaries, config files, images, style sheets, etc.) are stored on a web server somewhere and you would "run" the application by making a request to that web server, which takes the form of browsing to a URL in your web browser.

Umbraco 7 in Azure cloud as web roles

I have been trying to get Umbraco working in a web role environment (web services) in Azure, but the site errors when you try and access it, saying that config/trees.config is not accessible.
These are the steps i carried out:
Create a new empty MVC4 project in Visual Studio 2013
Install Umbraco v7.1.8 from nuget
Run up and configure using a new azure SQL database.
Added in the umbraco folders to the solution.
Added an azure web services project to the solution.
Added the existing MVC umbraco project to the azure role profiles.
Published to Azure staging area.
The site starts up with the usual 'Looks like there is still work to do' screen in the full Azure emulator in visual studio with multiple role instances. However fails to run up when hosted in Azure.
I am currently assuming that the issue is that the site root does not have write access when hosted in Azure, so the IIS worker process cannot write to the trees.config file.
I found an article where you can add a 'startup.bat' file, with the following:
echo "starting startup task" >> log.txt
%windir%\system32\Icacls.exe .. \* /T /grant "Network Service":(F) > log.txt
But this stops the role instances for starting up at all in both the emulator and when hosting in azure.
Any suggestions would be gratefully appreciated
I would suggest using a VM instead of a web role for hosting Umbraco in Azure, particularly since Umbraco is needing local write access to persist.
Web roles expect your application to be stateless, meaning no writing or persisting anything to the actual file system. This guarantee allows Azure to make certain assumptions so that it can load balance and scale the application correctly (it basically saves a master copy and then re-deploys it fresh as it scales up or makes updates, etc. This works great for web apps that were created with this in mind, but if not, then a VMs allows you to scale UP without worrying about your app needing to work a certain way to properly scale OUT under a load balancer (which is what web roles are made to help you do).
So, basically I would suggest installing to a Virtual Machine. It's still in the cloud, and you get all the cloud benefits of on-demand scaling of the infrastructure. In addition, I would expect Virtual Machines to be a supported install of Umbraco, where a web role install would not. Hope that helps!

How do you deploy a MVC4 .net app to production WITHOUT Web Deploy

I'm trying to deploy one of the default template apps that VS2012 generates for MVC4 to a production server (not on Azure).
It turns out that I'm not smart enough to figure out how to get Web Deploy working. After spending an hour on diagnosing different 404s, 403s, and 401s, I am ready to either ditch Web Deploy altogether, or start my project using PHP instead.
Can I just copy and paste my files and put them somewhere?
I'm fine with manually updating the database schema.
Anything else that needs to be updated?
You can publish directly to "File System" via "Publish" menu in VS (choose folder on production server). Then create WebApp on IIS with this folder (on the server) choose ApplicationPool 4.0 open port for your application if needed and start it.
What in the world makes you even think you need to use web deploy? You do realize that the web publishing wizard has several options to choose from, including FTP, file system, etc... I don't see how you could miss these.

Azure cloud service publishing - where does it go?

I created an asp.net mvc project in VS. I created an azure cloud service. Within the VS solution I added an azure project to enable me to publish to my cloud service. The cloud service has a web role and it’s published to a production environment. When I publish the project, I have my domain .cloudapp.net and I can then view my published project from a browser.
Job done. All good so far.
What I’m unclear on (and this is partly because my azure and asp.net mvc knowledge is limited) is where the project files actually reside (and the file/folder structure) and how to access them? I know they are on an IIS server somewhere but that’s about it.
With ‘traditional’ websites you have a webserver, a wwwroot folder and you stick your web pages etc into them and can see/access them through ftp etc.
Apart from wanting to know the answer to the above question I actually want to farm out the web ui (view) part to a web developer whilst I concentrate on the back end stuff. He doesn’t have visual studio so I’m unclear on how to best approach this?
I’ve noticed on the windows azure publish summary within my solution that you can enable remote desktop and enable web deploy which I suspect may be of help to me but as the solution is all working fine at the moment and I’m demoing it to a client tomorrow I’m a bit reluctant to make any last minute changes..as I’m sure we’ve all suffered the consequences of that before.
What I’m unclear on is where the project files actually reside
(and the file/folder structure) and how to access them?
As you have mentioned, these files reside on the server itself. If you connect to your server via Remote Desktop, you can see the files under D:\sitesroot folder (actual name of the folder can be found by launching IIS Manager on that server).
Having said that, it is not recommended to make changes to the files directly on the server. This is because if your server goes bad for any reason, Microsoft will provision a new server for you and it takes the code from the package file when you last deployed your application. This the changes you have made on that server will be lost.
Regarding your other question about having somebody focus on front-end development, I'm pretty sure you don't want him to working on production server directly. I'm assuming you have a centralized code repository somewhere where everybody checks in their code and then you build stuff and then deploy it.

Deploying a MVC4 website to Azure storage

I am developing a website in Mvc4 using visual studio 2012 and now I am facing a problem regarding web deployment or I can say that I'm not getting solution for this problem.
My problem is that I want to publish my website from my website view I want to give a button in home page of my website as I click on that button my database updates in IIS or azure server. How can I do this any idea about it ??
I am Currently Using Azure Storage and IIS server for local testing.
if you want to do deploy for "Azure WebSite" and not "Azure WebRole" you may use FTP transfer.
if you want to do deploy for WebRole, the first thing you have to open Remote Desktop on it and probably PowerShell will help you to deploy. You may find more details on that subject in Azure Enable Web Deploy via automated deployment and Powershell - Create Azure Deployment Package
Also please keep in mind that your infrastructure must be in separate environment. If you try to control publish/deploy from a same site (say you are on Site X and you are deploying for Site X) if anything goes wrong, you will lose all the control.

Resources