Azure, Deployment

Deploying an MVC app on Azure

Why deploy on Azure?

I’m not an expert on a lot of services offered online for developers. But I’m an expert student, that is from being one for 4 years. And I do know that as a student you can’t afford many of the online services, that is unless you sacrifice your money for buying noodles for 6 months.

The companies offering these services know that students can’t afford stuff, hence they put up stuff (packages) free for students. Azure is free for students via an Imagine subscription.

Okay! Now, lets assume you’re an MVC C# developer and you’ve developed this rad app. You wanna hook it up on the cloud so your friends can see it. Among many other services you should go for Azure…because its free.

Prerequisite

  • Azure Account
  • Imagine Subscription
  • Visual Studio

Create a Web App

Head over to the Azure portal and sign in and you’ll land on the dashboard. Aligned vertically on the left is the navigation, click on App Services and that will bring the window below:

Make sure on Subscriptions there is Imagine or anything but you should have some sort of sub otherwise you can’t deploy.

Next step is to click on +Add and that will bring a window on the right with a lot of cool stuff:

Click on Web App, another window to the right will slide to create a Web App. Further down, click on create. Add the details below, its actually just an app name. I named mine codeffee, and this means the url to my application will be codeffee.azurewebsites.net

When its done processing (deploying), click on App Services on the left and click the newly created app. Then click on Get publish profile. An XML file will downloaded.

Create SQL Database

I’m assuming your application does have a database, if it doesn’t that fine too. On the left vertical navigation again, click on SQL Database. A right window will slide in, click on +Add on the top. Fill in the details required and then click on Server and then click on Create New Server, the enter server credentials. NOTE: Make sure you remember the username and password. You’ll use these in a Connection String.

Once you done, click on select, the server window will close. Then click on create to create the database. Wait until it finishes deploying. Once its done, click on SQL Databases on the left navigation, then click on the database you created.

Click on Show database connection strings and then copy the string to your clipboard, make sure that its on ADNO.NET

App Config on Visual Studio

Right-click on the project and click on Publish… on the window that pops up, click on Import > Browse and get that XML file that was downloaded, then click Ok. It should bring up the window below

Press Next. Then on the following window, paste your Connection String on Context and enter your server {password} and {user id} check both boxes. Then click Next.

The final step is to click Start Preview > Publish.

Testing Application

Visual studio automatically open up your browser when its done deploying and goes to your app.

Testing Database

Try to Register, if you’re successfully registered, then that means there’s a successful connection to your database

Then you’re done!

“If it’s given for free, use it!”

1 thought on “Deploying an MVC app on Azure

Leave a Reply

Your email address will not be published. Required fields are marked *