The app we're going to build needs just one Web API controller which handles data requests, and a static website based on bootstrap starter kit.
For JsonStorage.net I'll use DocumentDB (yes, one more Azure service) as a back-end storage, It has native .NET API and provides awesome performance - just take a look at a latency graph:
I'll start with the simplest plan which costs 25$ per month, plus some extra depending on the storage used.
I'll use ASP.NET Web Application template, and also include Application Insights into the project so that we can monitor site performance and easily diagnose issues.
Now let's create a new Azure App Service, we can do it directly from Visual Studio.
Then click "OK", the resources will be provisioned and you'll be able to start coding. One thing you may need to configure additionally is Application Insights.
It is also pretty straightforward, basically you just confirm that you understand the pricing.
The solution is now ready and you can deploy it right away. In order to do that we need a publishing profile which can be downloaded from the portal:
Note that it is hidden in the "More" menu - took me a while to find it. Now right-click the project in Visual Studio, click "Publish", and import the profile.
Then click "Publish" and your solution will be deployed to Azure.
Now create a Web API controller which will handle requests from clients and store/retrieve data from the DocumentDB.
Our GET request handler will return the item from the DB by its ID:
POST will create a new item:
PUT will update the existing one:
The storage is just a simple DocumentDB repository which I will omit in this blog post since it basically just instantiates new DocumentClient(new Uri(EndpointUri), PrimaryKey); and calls it's methods.
Now the back-end logic is ready, we can simply add front-end theme (it might be easier to manage a static index.html file in the web root rather than standard controllers / views) and our site is ready - https://jsonstorage.net/.
It took me less than a few hours to build the site from idea to working prototype, all hosted in cloud! Here's the cost breakdown of the paid services:
- Domain name: 10$ / year
- SSL Certificate: 69.99 / year
- App Service Plan: 1.08$ / day
- DocumentDB: 0.78$ / day