Deploy an Angular App from Visual Studio Code to Azure

Deploy an Angular App from Visual Studio Code to Azure

Deploy an Angular App from Visual Studio Code to Azure - What do you get when you mix Angular 6, Node 10, Visual Studio Code and Azure? A really quick and slick way to develop and deploy a web application using the latest and greatest technologies. Keep reading to find out how.

Deploy an Angular App from Visual Studio Code to Azure - What do you get when you mix Angular 6, Node 10, Visual Studio Code and Azure? A really quick and slick way to develop and deploy a web application using the latest and greatest technologies. Keep reading to find out how.

This article will discuss how to:
  • Setup a free Node server on the cloud using Azure App Service
  • Build a basic Angular 6 web app running on Node 10
  • Use Visual Studio Code to deploy the web app from a local development machine to Azure
Prerequisites

You will need a free Microsoft Azure account with any Azure subscription. If you don’t have a paid subscription, a Pay-As-You-Go subscription is fine. All Azure services used in this article are free for development and testing purposes.

You will also need the following tools installed on your development machine:

  • Setup a free Node server on the cloud using Azure App Service
  • Build a basic Angular 6 web app running on Node 10
  • Use Visual Studio Code to deploy the web app from a local development machine to Azure

The instructions in this article assume Visual Studio Code v1.28, Node 10.6.0 and Angular CLI v6.1.1 although other versions may work too.

Set Up a New Web App on Azure

The first thing to do is setup the Web App (server) on the Azure cloud. The Azure portal or the Azure CLI can be used to create a new Web App. This article will demonstrate how to setup a server using the Azure portal.

To setup a Node.js server on Azure, you will need to create an App Service plan and a Web A_pp_. The App Service plan will be created on the F1 Free tier which provides a basic free virtual server suitable for development (1 GB ram, 1 hour CPU time / day).

To create the App Service plan:

  1. Locate “App Service plan” using the resource search in the Azure Portal
  2. Fill in the App Service plan name, Resource Group and make sure you select the “F1 Free” pricing tier. The free pricing tier can be found under the “Dev / Test” tab.

To create your Web App:

  1. Locate “App Service plan” using the resource search in the Azure Portal
  2. Fill in the App Service plan name, Resource Group and make sure you select the “F1 Free” pricing tier. The free pricing tier can be found under the “Dev / Test” tab.

You should now see your App Service plan and Web App on your Azure dashboard.

The web server is now ready.

You might be wondering why you don’t have to specify the type of web server to use when creating an Azure Web App. This is because Azure Web Apps conveniently support .NET, .NET Core, Java, Node.js, PHP and static HTML websites out of the box.## Set up Local Development Environment

The next step is to set up a local development environment including a local Node.js server, an Angular 6 application, Visual Studio Code and the Azure App Service extension.

The Local Node.js Server

A Node.js server needs to be installed on your development machine to build and test locally. I recommend that you use the Node Version Manager (NVM) command-line utility to manage and switch between multiple Node.js versions installed on your development machine. If you have NVM installed, installing the right version of Node.js is as simple as running these commands:

nvm install 10.6.0 64
nvm use 10.6.0

You should always make sure that your local server and remote server versions are in sync. Azure Web Apps support many versions of Node.js including v10.6.0.

The Angular App

You can generate an Angular 6.x app shell using the Angular CLI:

npm install -g @angular/cli
npm new canadian-maple

Alternatively, if you want to work with something a little more flashier and Canadian then clone the official Canadian Maple app from GitHub. The rest of this article will assume you did!

Visual Studio Code

Visual Studio Code combined with the Azure App Service extension can be used to develop, package and deploy the web app to Azure cloud.

Open up Visual Studio Code in the directory of your Angular app. Use the ng serve command in the integrated terminal (CTRL-~ shortcut) to run and verify your app .

Azure App Service Extension

Install the Azure App Service extension from the Visual Studio Code marketplace. After installing the extension and reloading Visual Studio Code, you will notice a new Azure icon in the left navigation bar. Click on the Azure icon to open the extension and select the option to sign into Azure.

After signing into Azure, you will see the “canadianmaple” Web App that was created previously.

You might be wondering why you don’t have to specify the type of web server to use when creating an Azure Web App. This is because Azure Web Apps conveniently support .NET, .NET Core, Java, Node.js, PHP and static HTML websites out of the box.> You might be wondering why you don’t have to specify the type of web server to use when creating an Azure Web App. This is because Azure Web Apps conveniently support .NET, .NET Core, Java, Node.js, PHP and static HTML websites out of the box.## Update Node Version on Azure Web App

Chances are the default version of Node on the Azure Web App is not the version that you want to use. Luckily, the version of node can be changed with the WEBSITE_NODE_DEFAULT_VERSION environment variable. Navigate to the Application settings section of the Application settings page for your Azure Web App. Click on the environment variable value to change it to 10.6.0.

You might be wondering why you don’t have to specify the type of web server to use when creating an Azure Web App. This is because Azure Web Apps conveniently support .NET, .NET Core, Java, Node.js, PHP and static HTML websites out of the box.
After changing the Node version, you can verify that the setting took effect by using the Console development tool and issuing the node -v command:

Deploying the App

Build the web application before deploying with the ng build command. This command will create the dist/canadian-maple directory containing a transpiled, minified, ready-to-deploy version of your application.

Deploying to an Azure Web App is as simple as right-clicking on the web app in the Azure App Service extension and selecting the “Deploy to Web App” option. The extension will make a suggestion on what to deploy but use the Browse option to select the dist/canadian-maple folder instead.

You will see a few prompts and notifications:

  • Setup a free Node server on the cloud using Azure App Service
  • Build a basic Angular 6 web app running on Node 10
  • Use Visual Studio Code to deploy the web app from a local development machine to Azure

Once the deployment is complete, you will receive a notification with a convenient button to browse to the site.

You have just deployed an Angular 6 app running on Node 10.6.0 to the Azure cloud… relatively painlessly! Check out http://canadianmaple.azurewebsites.net to see a live example.

Recap

Let’s recap what has been accomplished:

  • Setup a free Node server on the cloud using Azure App Service
  • Build a basic Angular 6 web app running on Node 10
  • Use Visual Studio Code to deploy the web app from a local development machine to Azure

Now wasn’t that fast and painless?

*Originally published by Brian De Sousa at *https://briandesousa.net

==========================

Follow me on Facebook | Twitter

Learn More

☞ Angular 8 (formerly Angular 2) - The Complete Guide

☞ Learn and Understand AngularJS

☞ The Complete Angular Course: Beginner to Advanced

☞ Angular Crash Course for Busy Developers

☞ Angular Essentials (Angular 2+ with TypeScript)

☞ Angular (Full App) with Angular Material, Angularfire & NgRx

☞ Angular & NodeJS - The MEAN Stack Guide

Debugging Angular CLI Applications in Visual Studio Code

Debugging Angular CLI Applications in Visual Studio Code

In this post, we are going to create an Angular CLI application, then add configuration to debug it in Visual Studio Code.

In this post, we are going to create an Angular CLI application, then add configuration to debug it in Visual Studio Code.

For an Angular CLI application, create a debug configuration in VS Code, install the Debugger for Chrome extension, then run in debug mode.

Learn VS Code

If you’re interested in learning more about VS Code, you definitely want to check out the upcoming Learn VS Code course.> If you’re interested in learning more about VS Code, you definitely want to check out the upcoming Learn VS Code course.# Creating a Starter Project

To be able to test an Angular CLI application, you need an Angular CLI application :) I’ll provide the basic steps, but for more reference on how to get started look at the Angular CLI page.

First, you’ll need to install the Angular CLI.

npm install -g @angular/cli

After that finishes, you’ll need to actually generate your new application. This will take a bit as it needs to install LOTS of NPM packages.

ng new my-app

Open the project in VS Code and you should see the following.

Now, that you’ve got your new fancy Angular app, go ahead and run it to make sure everything looks right.

ng serve

Should look like this.

Creating Debug Configuration

Assuming you’ve made it this far, we are ready to start debugging! Before we do, however, it’s worth understanding how configuring debugging in VS Code works. Basically debug configurations are saved in a launch.json file which is stored inside of a .vscode folder. This .vscode folder is used to store different configurations for Code including our required debugging stuff.

Before you create your debug configuration, you need to install the Debugger for Chrome extension. Find and install this extension from the extension tab in VS Code. After installing, reload VS Code.

Now, to create a debug configuration, you can open the debug panel (the bug looking button on the left panel). At the top of the debug panel, you should see a dropdown that says “No Configurations”.

To the right of that dropdown, there is a gear icon. Click this button to have VS Code automatically generate that .vscode folder and launch.json file mentioned above.

Then choose Chrome.

You should get the following configuration created for you.

The only thing we need to do is update the port from 8080 to 4200.

Let’s Debug

Now we’re ready! Go ahead and click the play button at the top of the Debug panel which will launch an instance of Chrome in debug mode. Keep in mind your app should already be running from using ng serve earlier. In VS Code, you should see the Debug toolbar pop up.

With this up and running, you can set a breakpoint in your App.component.ts. Open up your App.component.ts and add a breakpoint inside of the component by clicking in the gutter (to the left of the line numbers). Should look like this.

Now, refresh debugging by clicking the refresh button on the debugging toolbar. This should open your application again and trigger this breakpoin. You should be directed back to VS Code directly to the place where you set your breakpoint.

From here, you can set more breakpoints, inspect variables, etc. If you are interested in learning more about debugging JavaScript in general in either Chrome or VS Code you can check out Debugging JavaScript in Chrome and Visual Studio Code.

Learn more

Angular 7 Tutorial - Learn Angular 7 by Example

Build a Simple Web App with Express, Angular, and GraphQL

Build a Basic CRUD App with Laravel and Angular

AngularJS tutorial for beginners with NodeJS, ExpressJS and MongoDB

MEAN Stack Tutorial MongoDB, ExpressJS, AngularJS and NodeJS

Angular Authentication Tutorial

Angular 7 + Spring Boot CRUD Example

Angular 7 + Spring Boot Login Authentication Example

Angular 7 (formerly Angular 2) - The Complete Guide

Angular & NodeJS - The MEAN Stack Guide

Learn and Understand AngularJS

Angular Crash Course for Busy Developers

Python in Visual Studio Code

Python in Visual Studio Code

Python in Visual Studio Code

This post was written by Luciana Abud, Program Manager for the Python Extension in Visual Studio Code

We are pleased to announce that the January 2019 release of the Python Extension for Visual Studio Code is now available. You can download the Python extension from the Marketplace, or install it directly from the extension gallery in Visual Studio Code. You can learn more about Python support in Visual Studio Code in the documentation.

In this release we have closed a total of 62 issues, including:

  • IPython console support in the Python Interactive window
  • Support for running an entire file in the Python Interactive window
  • Problems for failed tests when using pytest (thanks Chris NeJame)
  • Much faster outline when using the Python Language Server

Keep on reading to learn more!

IPython console support in the Python Interactive window

The data science experience was first introduced in the last October release, and one of the top feedback requests we’ve heard was to provide the ability to iterate rapidly by experimenting with code in an interactive console environment. In this update, we extended the Python Interactive window with IPython console support by allowing code to be typed in and executed directly in the window. You can now use the enhanced Interactive window standalone as an IPython console, or send code from the editor for execution.

Here’s how to use it in a nutshell:

  • IPython console support in the Python Interactive window
  • Support for running an entire file in the Python Interactive window
  • Problems for failed tests when using pytest (thanks Chris NeJame)
  • Much faster outline when using the Python Language Server

Run an entire file in the Python Interactive window without cells defined

Being able to run code in the Python Interactive window without having to define cells is no doubt one of the most requested features. This update enables running the entire files in the Interactive window without cell definitions.

To run the entire file, simply use the command Run Current File in Python Interactive window in the Command Palette. Your code will be executed with results displayed in the Python Interactive window.

We’ve also heard requests to run the current code selection / line in the editor, and this will be coming next in a future update.

Diagnostics for failed tests with pytest

This release also includes an enhancement to unit tests run with pytest: you can now see failed tests in the problems window. You can also double click lines to navigate to the failed test method and the exact failing line. The correspondent line in the editor will be selected, allowing you to easily identify and edit it.

As before, you can also see failed tests highlighted with pass/fail icons in the editor. You can hover these icons to see the errors navigate to the failing test method/line, just like in the problems window.

We’d like to thank community contributor Chris NeJame for implementing this new feature. Contributions to the Python extension are always welcome! If you’re interested, check our contributing guide to learn more.

Much faster outline view with the Python Language Server

We also made improvements to the outline view when using the Microsoft Python Language Server. The Outline view could often take a long time to load or even time out, and now with the Language Server It now loads consistently fast, and cases where symbols would appear duplicated were fixed.

As a reminder, the Language Server was released as a preview the last July release of the Python extension. To opt-in to the language server, change the python.jediEnabled setting to false in File > Preferences > User Settings. We are working towards making the language server the default in future releases.

Original source: https://blogs.msdn.microsoft.com

 ===================================================================

Thanks for reading :heart: If you liked this post, share it with all of your programming buddies! Follow me on Facebook | Twitter

Learn More

☞ Complete Python Bootcamp: Go from zero to hero in Python 3

☞ Python for Time Series Data Analysis

☞ The complete beginner’s guide to JSON

☞ The Complete Guide to JSON Web Tokens

☞ Python Programming For Beginners From Scratch

☞ Python Network Programming | Network Apps & Hacking Tools

☞ Intro To SQLite Databases for Python Programming

☞ Ethical Hacking With Python, JavaScript and Kali Linux

☞ Beginner’s guide on Python: Learn python from scratch! (New)

☞ Python for Beginners: Complete Python Programming