I recently gave a “Rather Useful Seminar” at Hull University in which I talked about and tried to show off how we can do cool things using the free Microsoft Azure subscription that students can access through Microsoft’s DreamSpark program. One of the things I went through was setting up a server to store and retrieve high scores from a web server.
However, there’s only so much I can get across in a 10-minute talk, so in this post I’m going to go through that in more detail. I’m going to assume that anyone reading this has at least basic knowledge of programming in C#, but not necessarily any experience with web development. If you need to brush up on C#, I’d recommend Rob Miles’ Yellow Book.
To follow along, you’ll need three things:
- A Microsoft account
- The Azure SDK (which you can download from Microsoft’s website)
- A copy of Visual Studio 2015 – any edition (including Community) should work
Microsoft Azure is Microsoft’s cloud platform. A bunch of server farms located all over the world are operated by Microsoft, and you can host things on them such as web apps and databases and access them from anywhere. A big advantage of this is that it lets you run an app, store data, and retrieve data without needing any infrastructure. That’s useful for students, especially, as it means that the university doesn’t have to host anything, and you don’t need access to a physical server to run anything either – Microsoft takes care of all of that for you. All you need to do is publish your app.
Setting up an Azure subscription
If you have a DreamSpark subscription through your university, you can set up an Azure account for free, by doing the following:
- Go to the DreamSpark software catalogue: https://www.dreamspark.com/Student/Software-Catalog.aspx
- Select “Microsoft Azure for DreamSpark” under “Servers and Applications”
- Follow the instructions to finish setting up your account. You will be asked to provide proof of academic enrolment. Usually, this involves confirming your identity with your .ac.uk email address or entering credentials for your account at the university.
- You’ll be able to link your Azure subscription to a Microsoft account here – one you’ve done this, you’re good to go with your Azure subscription.
What we’re making
What this post will go through is the basics of setting up a server to store high scores on a video game. To do this, we’ll be setting up a web service with a REST API which lets us retrieve scores and submit them. Then, to store the scores between sessions, we’ll be linking the web service to a MySQL database.
Then, select “Web API” from the list of templates. Set the “Authentication” to “No Authentication”.
To make things a bit easier later on, sign in to Visual Studio using the Microsoft account your Azure subscription is linked to.
Setting up a web app on Microsoft Azure
On the last screenshot, you probably noticed a checkbox saying “Host in the cloud”. If you tick it, you’ll be prompted to create a new web app on Azure from within Visual Studio, and your site can be published to there. You can also create a web app after creating your project, which is what we’re going to go through here.
Setting up a web app is relatively easy. The first thing you need to do is go to manage.windowsazure.com and sign in with the Microsoft Account you used to set up your Azure subscription.
Give it a unique name (the portal will validate it to make sure it’s unique), select “Dreamspark” under “Subscription”, and click “Create” to start creating a new web app on Azure. As you haven’t uploaded anything to it yet, this is basically a placeholder for now.
Publishing our app to Azure
On the wizard, select “Microsoft Azure App Service” and click “Next”. On the list of web apps, select the app you just set up and click “OK”. Finally, click “Publish” to upload all the files from your web app, and you now have a site hosted in the cloud.
You’ve probably noticed that there’s nothing but the default content on our web service. Next post, I’ll go through linking a database to our site and setting up a custom API.