Microsoft Azure Open Source Development Support Team Blog

Support for Open Source Technologies on Microsoft Azure App Service

Creating an AngularJS Single Page Application with routes on Azure WebApps

This Blog would provide a step-by-step procedure on creating sample AngularJS app with routes supporting SEO.

Source code is available on github @

1) Create a new Azure web app from portal.

2) Setup continuous deployment process.

3) Create a HTML file(index.html) with below content which would act as entry point to AngularJS app. A div tag with ng-view is an important part of this file.

<link rel="stylesheet" type="text/css" href="assets/bootstrap/css/bootstrap.min.css">
<script type="text/javascript" src="assets/angularmodules/angular.min.js"></script>
<script type="text/javascript" src="assets/angularmodules/angular-route.min.js"></script>
<script type="text/javascript" src="assets/app.js"></script>
<base href="">
<body ng-app="giveCampaign">
<div class="col-md-3">
<ul class="nav">
<li><a href="donarlist"> Donar List </a></li>
<li><a href="receivertrans"> Receive</a></li>
<div ng-view></div>

4) Create a new directory(assets) to store all other files.


5) Create an app.js file inside assets folder which would have our app specific angularJS code. Below is for our sample app which has two controllers and route config.

var app = angular.module("giveCampaign",['ngRoute']);

app.config(['$routeProvider','$locationProvider',function($routeProvider, $locationProvider) {

$routeProvider.when('/donarlist', {templateUrl:"assets/templates/donarlist.html",controller:'DonarController'}).when('/receivertrans',{templateUrl:"assets/templates/receiver.html",controller:'ReceiverController'}).otherwise({redirectTo: '/abc'});

app.controller('DonarController', function(){
this.recentTrans = recentTransactions;


var recentTransactions =[
{donatedTo:"justin Tim",
donatedBy:"Cristhian Uribe"
{donatedTo:"bryan lynch",
item:"baseball bat",
donatedBy:"richard marr"




6) Our AngularJS project would require few angular libraries. Either you can download them and insert in assets/angularmodules folder (or) use existing CDN in index.html file.


7) I have created two different templates inside assets/templates folder to show a view based on incoming url

ex: – url ending with /donarlist should show all the donars of charity foundation (donarlist.html)

      – url ending with /receiver should show a form to fill required details. (receiver.html)


<div ng-controller="DonarController as donarCtrl">
<div ng-repeat="transaction in donarCtrl.recentTrans">
<div>{{transaction.donatedBy}} has donated a {{transaction.item}} worth of {{transaction.cost | currency}} to {{transaction.donatedTo}}</div>


<div ng-controller="ReceiverController as recCtrl">
<form name="needForm">
<label>Name: </label>
<input ng-model="" type="text" />
<label>Email: </label>
<input ng-model="" type="email" />
<label>Need: </label>
<input ng-model="" type="text" />

8) Create a web.config file which would establish incoming url routes from IIS to index.html page. Below is a working sample 

<?xml version="1.0" encoding="UTF-8"?>
<clear />
<!-- ignore static files -->
<rule name="AngularJS Conditions" stopProcessing="true">
<match url="(app/.*|assets/.*|config/.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="None" />
<!-- check if its root url and navigate to default page -->
<rule name="Index Request" enabled="true" stopProcessing="true">
<match url="^$" />
<action type="Redirect" url="/receivertrans" logRewrittenUrl="true" />
<!--remaining all other url's point to index.html file -->
<rule name="AngularJS Wildcard" enabled="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="index.html" />

9) Code is available on github @

10) Below are screen shots of a sample app with above code on azure

/donarlist url


/receiverlist url