Microsoft Azure for Spoiled People
Tags: javascript, webdev, beginners, vue
Published: 2019-05-21 18:44:36

---
title: Microsoft Azure for Spoiled People
published: true
description: There may come a time in your career when you have to move from platforms such as Firebase and Netlify for app deployment to a more enterprise-focused platform such as Microsoft Azure. Here's an empathetic post for all the Spoiled People.
tags: javascript, webdev, beginners, vue
cover_image: https://media.giphy.com/media/mWHIJqgCFtpzW/giphy.gif
series: Azure-For-Spoiled-People 
---

I'm spoiled by great software. Really spoiled, because I've had the luxury of choosing my favorite platforms and deploying to them in my role as a Developer Advocate and indie app developer. I've become used to creating cute demos that are deployed fast in order to showcase this or that technology. To do this, I have at my disposal really, really nice software platforms, but many of my [very cute apps](http://jenlooper.com) never make it anywhere near production distribution. 

> Disclosure, I'm now a Microsoft employee. Apparently it's time to get serious.

I was first spoiled by Parse, and released a bunch of small apps that used its database and sweet push notification services for my web and mobile backend. Then Parse's official service was shut down in 2017* after it was acquired by Facebook. 

![tantrum](https://media.giphy.com/media/gwK8djpnM8lt6/giphy.gif)

After causing a scene that is best forgotten, I moved to Firebase. It truly was the next best thing for realtime database updates, push notifications, and analytics. Eventually it even included really cool machine learning integrations with the advent of ML Kit. And, lo and behold, Firebase offered web hosting! That was nice! I could use it both as a sweet MBaaS** AND site hosting.

Like kids in the ~~candy store~~ chocolate factory, developers are often attracted to these beautifully-designed platforms for their smaller apps as long as they are cost-effective, showcase well, and can get a project and running as quickly as possible.

![choco factory](https://media.giphy.com/media/slkPSzf2jgWqs/giphy.gif)

At some point, however, you might need to scale up from your small to medium-sized personal projects. What if you're working in an environment where your projects grow beyond the resources or features offered by awesome platforms such as Firebase? In this series of tutorials, I'm going to talk about how to deploy a web project on Microsoft's robust, enterprise-friendly cloud offering, Azure. In future tutorials, I'll show you how to scale it by adding a database and more. So let's get started. 

> 🍬🍫🍭 If you'd like to learn about Azure, take a look at [its myriad offerings](https://azure.microsoft.com/en-us/free/?wt.mc_id=devto-blog-jelooper) 🍬🍫🍭

In this article, I'm going to walk you through the easiest possible way to set up a Vue.js CLI-built web app on Azure with continuous integration via GitHub, because spoiled people like us have no time to waste.

Note, there are a lot of great tutorials on how to host static sites on Azure, like [this one](https://medium.com/microsoftazure/deploying-create-react-app-as-a-static-site-on-azure-dd1330b215a5). This involves posting your static site files within Azure storage. I actually am not looking to host a static site; rather I want to build a Vue app using the Vue CLI and push it to GitHub, to be picked up by a build process whenever you push changes to GitHub. 

Ideally, Azure-style web hosting would look less like Firebase-style web hosting which entails building locally and using the Firebase CLI to upload and deploy your content, and more like Netlify's super easy continuous deployments for Vue apps where changes are pulled from GitHub automatically, built and deployed. Once the web hosting is taken care of, I'll have a clean process for updating a web site that I can later enhance with the other tools in Azure's portfolio.

## Step 1: Create an Azure account

For testing purposes and to get up and running with your new web app, you can create a free account by [signing up for Azure](https://azure.microsoft.com/en-us/free/?wt.mc_id=devto-blog-jelooper).

![sign up for Azure](https://thepracticaldev.s3.amazonaws.com/i/kda5lf6gi6rnq5bjkwxr.png)

Once you have signed up for Azure, you'll find the Azure portal. This is where you can manage app creation, deployment, and additional implementations like ML and database management. You can also do a lot of this management via the Azure CLI or with VS Code app extensions (described below), but the portal allows you to keep track, visually, of your apps, and I find that helpful.

> Helpful tip: as you create assets in the Azure portal, pin them to your personal dashboard by clicking the pushpin icon on the top right. They'll be easier to find later.

## Step 2: Build your Vue.js app and configure VS Code

The absolute easiest way to create a Vue.js app is to use the Vue UI, a GUI that helps you visualize CLI processes. Once you have the [Vue CLI](https://cli.vuejs.org/) installed, open your terminal and type `vue ui` to witness this glory:

![vue ui](https://thepracticaldev.s3.amazonaws.com/i/lpm1freym8w7pqhz6nar.png)

Walking through the creation process of a new Vue CLI-built app will scaffold out a basic web app that you can start working on in Visual Studio Code, or any editor that you prefer. I recommend VS Code, however, because there are some amazing Azure extensions that make your life easier as you work with Azure. If you don't have these extensions installed, I encourage you to do so. There are a bunch of them: open the Command Palette and search for `Azure` in the VS Code marketplace.

![azure extensions](https://thepracticaldev.s3.amazonaws.com/i/uwkoq4d2d55tf9q1ldri.png)

At the very least, install the Azure Account, Azure Tools and Azure App Service extensions. Once these are installed, You should be able to log in to your Azure account from VS Code when prompted by the editor. Once you are signed in, you have access to all the various elements created for your team in Azure; to view them, you can click on the Azure logo in the VS Code sidebar. These can come in handy as you progress.

## Step 3: Get ready for deployment

Now you need to prepare your baby web app for deployment and continuous integration from GitHub. Vue apps are usually deployed from their build directories, usually `/dist` folders. Build your Vue app locally (`npm run build` or run a task in the Vue UI). 

Next, make sure that your app's .gitignore file doesn't include your newly-created `dist` folder: remove the .gitignore's reference to `/dist`. Go ahead and push your codebase to a GitHub repo.

Then, go into the [portal of Azure](https://portal.azure.com?wt.mc_id=devto-blog-jelooper) and begin creating an environment for your app. 

> Note: you will need a Subscription and a Resource Group for your apps. You might need to create a new Resource Group in the portal before you create your new web app.

1. Click 'Create a Resource' at the top left of the portal
2. Click 'Web App' in the middle panel
3. In the 'Basics' tab, select which Subscription and Resource Group to which you want to add your web app. For a completely new account, you probably need to create these in the portal.
4. Give your web app a name
5. Choose to publish with 'Code'
6. Pick your preferred version of Node in the Runtime stack dropdown.
7. Pick 'Windows' in the platform (this is important because we'll create a config file used by IIS to set the default document) 
8. Select a location for your resource near to you

![creation of a web site](https://thepracticaldev.s3.amazonaws.com/i/l7be3a6ojztis63n7don.png)

Then, save the configuration and deploy your app. Azure will create a web site at `azurewebsites.net` for you which you can access from the Overview tab. Without connecting it to your code, it just looks like this:

![burner app](https://thepracticaldev.s3.amazonaws.com/i/c1v6ctm0917rkeoc7s2o.png)

>Tip: you can save this resource to your dashboard; it's a good idea to do so as it's really easy to get lost in Azure.

## Step 4: Connect your Azure app to your codebase

Now, you need to tell Azure where to find your codebase. Since your baby Vue app is now safe in GitHub, head over to the Deployment Center tab in the portal and click 'GitHub'.

>Note, you need to connect GitHub to your Azure account

![connect to GitHub](https://thepracticaldev.s3.amazonaws.com/i/f3aiffxjwjkcwyczhuuh.png)

Click 'Continue', and select the 'App Service build service'. This is Kudu, an engine that builds and deploys your code.

![kudu](https://thepracticaldev.s3.amazonaws.com/i/bht6qijnuuxjhb0h8yts.png)

Click 'Continue' again, and select the appropriate area of GitHub to connect your app. When everything matches up, click 'Finish' to run your first deployment. 

![connect GitHub](https://thepracticaldev.s3.amazonaws.com/i/62vuevuaa8meyhui3r2z.png)

You can check the logs while it runs to see what's going on. This is helpful if there's a problem. You can also make sure that the build process is functioning as expected.

![watch the logs](https://thepracticaldev.s3.amazonaws.com/i/qjj76721j0jmh9133ny5.png)

If you were to visit your web site now, unfortunately, you'd see that it throws an error. A glance at the logs shows you what's wrong:

![](https://thepracticaldev.s3.amazonaws.com/i/d9ht89e7wme5u83avv1r.png)

Notice that "Missing server.js/app.js files, web.config is not generated" message? That's our clue that we need to add a web.config file to the app root to show Azure where to look for index.html (hint: it's `dist/index.html`, which we can see was copied by the build process).

All you have to do at this point is create that `web.config` file, with the following setup enumerated:

```
<?xml version="1.0" encoding="utf-8"?>
<!--
     This configuration file is required if iisnode is used to run node processes behind
     IIS or IIS Express.  For more information, visit:
     https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config
-->

<configuration>
  <system.webServer>
    <webSocket enabled="false" />
    <rewrite>
      <rules>
        <!-- First we consider whether the incoming URL matches a physical file in the /dist folder -->
        <rule name="StaticContent">
          <action type="Rewrite" url="dist{REQUEST_URI}"/>
        </rule>
      </rules>
    </rewrite>

    <!-- 'bin' directory has no special meaning in node.js and apps can be placed in it -->
    <security>
      <requestFiltering>
        <hiddenSegments>
          <remove segment="bin"/>
        </hiddenSegments>
      </requestFiltering>
    </security>

    <!-- Make sure error responses are left untouched -->
    <httpErrors existingResponse="PassThrough" />
  </system.webServer>
</configuration>
```

Remember how we set up our hosting to be run on Windows? Using Windows opens up IIS with iisnode for routing, and this file tells IIS where to find the default index.html page. Drop this web.config file in your app's root and push it to GitHub. The app should rebuild and redeploy automatically. And, if all goes well, you will have a beautiful Vue.js starter web site on an azurewebsites.net domain!

![a fresh web site](https://thepracticaldev.s3.amazonaws.com/i/1mzjkzyizyndsi3a5g6p.png)

In the next tutorial, I'll build out the website I'm working on and add a database. Spoiler alert, it's going to be called Azure cocktails, the data will be driven by my Mr. Boston Cocktails dataset, exported from Firebase and imported to Azure, and all the cocktails on the site will be blue. 

<blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">And for my first trick, I will use my Mr. Boston Cocktails dataset to power a new web app, Azure Cocktails. Only featuring blue cocktails. Because. <a href="https://t.co/OOj3Ebzax9">pic.twitter.com/OOj3Ebzax9</a></p>&mdash; Vx. Jen Looper (@jenlooper) <a href="https://twitter.com/jenlooper/status/1129476283853869056?ref_src=twsrc%5Etfw">May 17, 2019</a></blockquote>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

Stay tuned!

*[Parse](parseplatform.org) lives on as an open source, community-based project, and more power to it!

**MBaaS means 'mobile backend as a service'.

> Useful Links:
> 🕴[Azure Portal](https://portal.azure.com?wt.mc_id=devto-blog-jelooper)
> 🔌[Azure Extensions for VS Code](https://code.visualstudio.com/docs/azure/extensions?wt.mc_id=devto-blog-jelooper)
> 💚[Getting Started with Vue.js](https://vuejs.org/v2/guide/)
> 🎨[The Vue CLI with its UI](https://cli.vuejs.org/)