Setup Fanray on Azure

Setting up Fanray on Azure is straight forward, I’m starting from scratch and the process is done with the following two steps.

  • Create Azure resources, Web App and SQL
  • Deploy the application from GitHub

Create Azure resources: Web App + SQL

In Azure Portal, click on New and choose Web App + SQL template.  Following the steps will create the web app and database in one step and put the connection string in the web app’s Application settings. During this process, a Resource Group and Service plan will also be created.

Azure organizes resources like this,

  • Web: Subscription > Resource Group > Service plan > App services
  • SQL: Subscription > Resource Group > SQL server > SQL databases

Normally one gets started on Azure with a subscription. Under subscription there is Resource Group which is the container for your resources, it enables you to easily say delete your Resource Group or transfer it to different subscription, then all the resources will be deleted or transferred all together.

A Service plan contains one or more App services like web app, mobile app etc. and is where you scale up / out for our applications. A SQL server contains one or more SQL databases, but you scale up and down workloads on the individual SQL databases in the unit of DTUs. This article Tuning performance in Azure SQL Database explains the different database service tier and their performance.

I created one Resource Group, one Service plan (Basic Service plan, B1), one App Service, one SQL server, one SQL database (Standard SQL database, S0).  I see the following after I setup my resources, all these live in my Resource Group.

fanray_azure_resources

After creating all the resources, go to your App Service > Application settings, under Connection strings there should be an entry called “defaultConnection” pointing to the SQL server and database, create this entry if it’s not there.

fanray_application_settings_connection_strings

Deploy from GitHub

Code can be deployed to Azure in many ways, directly from GitHub is an easy way and you start by forking the Fanray repo on GitHub. Then go into App Service > Deployment options > Choose Source and select GitHub, then authenticate, choose project and branch.  Click OK and it will start initial deployment and any subsequent push of commits will trigger this deployment process.

fanray_github_deployment_options

Launch your site

At this time my azure website http://fanray.azurewebsites.net is up and running!  Visiting for the first time, the blog setup page will show up, fill it out and create your blog.

fanray_blog_setupwelcome_to_fanray

When you visit the site for the first time but before you see the setup page, Entity Framework would have created your database and populated the tables for you. Fanray blog use SQL Server in production by default, if you want to use SQLite in production go to appsettings.Production.json file and update the Database property on line 3 from “sqlserver” to “sqlite”.

Updating a setting can be done directly in Azure Portal, go to your App Service > App Service Editor which is preview right now, just launch it and find appsettings.Production.json and edit it.

App_Service_Editor

Summary

Getting started with Fanray blog on Azure is easy. The next step is to setup your own domain and https.