Skip to content

Commit ea6c772

Browse files
authored
Merge pull request #106510 from kraigb/kraigb-edits2
Revisions to fix Windows issues in Node.js quickstart for App Service
2 parents f42e91c + 488b088 commit ea6c772

File tree

3 files changed

+78
-105
lines changed

3 files changed

+78
-105
lines changed

articles/app-service/app-service-web-get-started-nodejs.md

Lines changed: 78 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2-
title: 'QuickStart: Create a Node.js web app'
2+
title: 'Quickstart: Create a Node.js web app'
33
description: Deploy your first Node.js Hello World to Azure App Service in minutes. You deploy using Visual Studio Code, which is one of many ways to deploy to App Service.
44
ms.assetid: 582bb3c2-164b-42f5-b081-95bfcb7a502a
55
ms.topic: quickstart
6-
ms.date: 09/30/2019
6+
ms.date: 03/04/2020
77
ms.custom: mvc, devcenter
88
ms.custom: seodec18
99

@@ -16,166 +16,139 @@ experiment_id: a231f2b4-2625-4d
1616
---
1717
# Create a Node.js web app in Azure
1818

19-
Azure App Service provides a highly scalable, self-patching web hosting service. This quickstart shows how to deploy a Node.js app to Azure App Service.
19+
Get started with Azure App Service by creating a Node.js/Express app locally using Visual Studio Code and then deploying the app to the cloud. Because you use a free App Service tier, you incur no costs to complete this quickstart.
2020

2121
## Prerequisites
2222

23-
If you don't have an Azure account, [sign up today](https://azure.microsoft.com/free/?utm_source=campaign&utm_campaign=vscode-tutorial-app-service-extension&mktingSource=vscode-tutorial-app-service-extension) for a free account with $200 in Azure credits to try out any combination of services.
23+
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?utm_source=campaign&utm_campaign=vscode-tutorial-app-service-extension&mktingSource=vscode-tutorial-app-service-extension).
24+
- [Node.js and npm](https://nodejs.org). Run the command `node --version` to verify that Node.js is installed.
25+
- [Visual Studio Code](https://code.visualstudio.com/).
26+
- The [Azure App Service extension](vscode:extension/ms-azuretools.vscode-azureappservice) for Visual Studio Code.
2427

25-
You need [Visual Studio Code](https://code.visualstudio.com/) installed along with [Node.js and npm](https://nodejs.org/en/download), the Node.js package manager.
28+
## Clone and run a local Node.js application
2629

27-
You will also need to install the [Azure App Service extension](vscode:extension/ms-azuretools.vscode-azureappservice), which you can use to create, manage, and deploy Linux Web Apps on the Azure Platform as a Service (PaaS).
30+
1. On your local computer, open a terminal and clone the sample repository:
2831

29-
### Sign in
30-
31-
Once the extension is installed, log into your Azure account. In the Activity Bar, select on the Azure logo to show the **AZURE APP SERVICE** explorer. Select **Sign in to Azure...** and follow the instructions.
32-
33-
![sign in to Azure](containers/media/quickstart-nodejs/sign-in.png)
34-
35-
### Troubleshooting
36-
37-
If you see the error **"Cannot find subscription with name [subscription ID]"**, it might be because you're behind a proxy and unable to reach the Azure API. Configure `HTTP_PROXY` and `HTTPS_PROXY` environment variables with your proxy information in your terminal using `export`.
38-
39-
```sh
40-
export HTTPS_PROXY=https://username:password@proxy:8080
41-
export HTTP_PROXY=http://username:password@proxy:8080
42-
```
43-
44-
If setting the environment variables doesn't correct the issue, contact us by selecting the **I ran into an issue** button below.
45-
46-
### Prerequisite check
47-
48-
Before you continue, ensure that you have all the prerequisites installed and configured.
49-
50-
In VS Code, you should see your Azure email address in the Status Bar and your subscription in the **AZURE APP SERVICE** explorer.
51-
52-
> [!div class="nextstepaction"]
53-
> [I ran into an issue](https://www.research.net/r/PWZWZ52?tutorial=node-deployment-azure-app-service&step=getting-started)
54-
55-
## Create your Node.js application
56-
57-
Next, create a Node.js application that can be deployed to the Cloud. This quickstart uses an application generator to quickly scaffold out the application from a terminal.
58-
59-
> [!TIP]
60-
> If you have already completed the [Node.js tutorial](https://code.visualstudio.com/docs/nodejs/nodejs-tutorial), you can skip ahead to [Deploy to Azure](#deploy-to-azure).
61-
62-
### Scaffold a new application with the Express Generator
63-
64-
[Express](https://www.expressjs.com) is a popular framework for building and running Node.js applications. You can scaffold (create) a new Express application using the [Express Generator](https://expressjs.com/en/starter/generator.html) tool. The Express Generator is shipped as an npm module and can be run directly (without installation) by using the npm command-line tool `npx`.
65-
66-
```bash
67-
npx express-generator myExpressApp --view pug --git
68-
```
69-
70-
The `--view pug --git` parameters tell the generator to use the [pug](https://pugjs.org/api/getting-started.html) template engine (formerly known as `jade`) and to create a `.gitignore` file.
71-
72-
To install all of the application's dependencies, go to the new folder and run `npm install`.
73-
74-
```bash
75-
cd myExpressApp
76-
npm install
77-
```
32+
```bash
33+
git clone https://github.com/Azure-Samples/nodejs-docs-hello-world
34+
```
7835

79-
### Run the application
36+
1. Navigate into the new app folder:
8037

81-
Next, ensure that the application runs. From the terminal, start the application using the `npm start` command to start the server.
38+
```bash
39+
cd nodejs-docs-hello-world
40+
```
8241

83-
```bash
84-
npm start
85-
```
42+
1. Start the app to test it locally:
8643

87-
Now, open your browser and navigate to [http://localhost:3000](http://localhost:3000), where you should see something like this:
44+
```bash
45+
npm start
46+
```
47+
48+
1. Open your browser and navigate to [http://localhost:1337](http://localhost:1337). The browser should display "Hello World!".
8849

89-
![Running Express Application](containers/media/quickstart-nodejs/express.png)
50+
1. Press **Ctrl**+**C** in the terminal to stop the server.
9051

9152
> [!div class="nextstepaction"]
9253
> [I ran into an issue](https://www.research.net/r/PWZWZ52?tutorial=node-deployment-azure-app-service&step=create-app)
9354

94-
## Deploy to Azure
95-
96-
In this section, you deploy your Node.js app using VS Code and the Azure App Service extension. This quickstart uses the most basic deployment model where your app is zipped and deployed to an Azure Web App on Linux.
55+
## Deploy the app to Azure
9756

98-
### Deploy using Azure App Service
57+
In this section, you deploy your Node.js app to Azure using VS Code and the Azure App Service extension.
9958

100-
First, open your application folder in VS Code.
59+
1. In the terminal, make sure you're in the *nodejs-docs-hello-world* folder, then start Visual Studio Code with the following command:
10160
102-
```bash
103-
code .
104-
```
61+
```bash
62+
code .
63+
```
10564
106-
In the **AZURE APP SERVICE** explorer, select the blue up arrow icon to deploy your app to Azure.
65+
1. In the VS Code activity bar, select the Azure logo to show the **AZURE APP SERVICE** explorer. Select **Sign in to Azure...** and follow the instructions. (See [Troubleshooting Azure sign-in](#troubleshooting-azure-sign-in) below if you run into errors.) Once signed in, the explorer should show the name of your Azure subscription.
10766
108-
![Deploy to Web App](containers/media/quickstart-nodejs/deploy.png)
67+
![Sign in to Azure](containers/media/quickstart-nodejs/sign-in.png)
10968
110-
> [!TIP]
111-
> You can also deploy from the **Command Palette** (CTRL + SHIFT + P) by typing 'deploy to web app' and running the **Azure App Service: Deploy to Web App** command.
69+
1. In the **AZURE APP SERVICE** explorer of VS Code, select the blue up arrow icon to deploy your app to Azure. (You can also invoke the same command from the **Command Palette** (**Ctrl**+**Shift**+**P**) by typing 'deploy to web app' and choosing **Azure App Service: Deploy to Web App**).
11270
113-
1. Choose the directory that you currently have open, `myExpressApp`.
71+
![Deploy to Web App](containers/media/quickstart-nodejs/deploy.png)
72+
73+
1. Choose the *nodejs-docs-hello-world* folder.
11474
11575
1. Choose a creation option based on the operating system to which you want to deploy:
11676
117-
- Linux: Choose **Create new Web App**.
118-
- Windows: Choose **Create new Web App** and select the **Advanced** option.
77+
- Linux: Choose **Create new Web App**
78+
- Windows: Choose **Create new Web App... Advanced**
11979
120-
1. Type a globally unique name for your Web App and press ENTER. Valid characters for an app name are 'a-z', '0-9', and '-'.
80+
1. Type a globally unique name for your web app and press **Enter**. The name must be unique across all of Azure and use only alphanumeric characters ('A-Z', 'a-z', and '0-9') and hyphens ('-').
12181
12282
1. If targeting Linux, select a Node.js version when prompted. An **LTS** version is recommended.
12383
124-
1. If targeting Windows using the **Advanced** option, follow the additional prompts:
125-
1. Select **Create a new resource group**, then enter a name for the resource group.
84+
1. If targeting Windows, follow the additional prompts:
85+
1. Select **Create a new resource group**, then enter a name for the resource group, such as `AppServiceQS-rg`.
12686
1. Select **Windows** for the operating system.
127-
1. Select an existing App Service Plan or create a new one. You can select a pricing tier when creating a new plan.
87+
1. Select **Create new App Service plan**, then enter a name for the plan (such as `AppServiceQS-plan`), then select **F1 Free** for the pricing tier.
12888
1. Choose **Skip for now** when prompted about Application Insights.
12989
1. Choose a region near you or near resources you wish to access.
13090
131-
1. After you respond to all the prompts, the notification channel shows the Azure resources that are being created for your app.
91+
1. After you respond to all the prompts, VS Code shows the Azure resources that are being created for your app in its notification popup.
92+
93+
When deploying to Linux, select **Yes** when prompted to update your configuration to run `npm install` on the target Linux server.
13294
133-
1. Select **Yes** when prompted to update your configuration to run `npm install` on the target server. Your app is then deployed.
95+
![Prompt to update configuration on the target Linux server](containers/media/quickstart-nodejs/server-build.png)
13496
135-
![Configured deployment](containers/media/quickstart-nodejs/server-build.png)
97+
1. Select **Yes** when prompted with **Always deploy the workspace "nodejs-docs-hello-world" to (app name)"**. Selecting **Yes** tells VS Code to automatically target the same App Service Web App with subsequent deployments.
13698
137-
1. When the deployment starts, you're prompted to update your workspace so that later deployments will automatically target the same App Service Web App. Choose **Yes** to ensure your changes are deployed to the correct app.
99+
1. If deploying to Linux, select **Browse Website** in the prompt to view your freshly deployed web app once deployment is complete. The browser should display "Hello World!"
138100
139-
![Configured deployment](containers/media/quickstart-nodejs/save-configuration.png)
101+
1. If deploying to Windows, you must first set the Node.js version number for the web app:
140102
141-
> [!TIP]
142-
> Be sure that your application is listening on the port provided by the PORT environment variable: `process.env.PORT`.
103+
1. In VS Code, expand the node for the new app service, right-click **Application Settings**, and select **Add New Setting...**:
143104
144-
### Browse the app in Azure
105+
![Add app setting command](containers/media/quickstart-nodejs/add-setting.png)
145106
146-
Once the deployment completes, select **Browse Website** in the prompt to view your freshly deployed web app.
107+
1. Enter `WEBSITE_NODE_DEFAULT_VERSION` for the setting key.
108+
1. Enter `10.15.2` for the setting value.
109+
1. Right-click the node for the app service and select **Restart**
147110
148-
### Troubleshooting
111+
![Restart app service command](containers/media/quickstart-nodejs/restart.png)
149112
150-
If you see the error **"You do not have permission to view this directory or page."**, then the application probably failed to start correctly. Head to the next section and view the log output to find and fix the error. If you aren't able to fix it, contact us by selecting the **I ran into an issue** button below. We're happy to help!
113+
1. Right-click the node for the app service once more and select **Browse Website**.
151114
152115
> [!div class="nextstepaction"]
153116
> [I ran into an issue](https://www.research.net/r/PWZWZ52?tutorial=node-deployment-azure-app-service&step=deploy-app)
154117
118+
### Troubleshooting Azure sign-in
119+
120+
If you see the error **"Cannot find subscription with name [subscription ID]"** when signing into Azure, it might be because you're behind a proxy and unable to reach the Azure API. Configure `HTTP_PROXY` and `HTTPS_PROXY` environment variables with your proxy information in your terminal using `export`.
121+
122+
```bash
123+
export HTTPS_PROXY=https://username:password@proxy:8080
124+
export HTTP_PROXY=http://username:password@proxy:8080
125+
```
126+
127+
If setting the environment variables doesn't correct the issue, contact us by selecting the **I ran into an issue** button above.
128+
155129
### Update the app
156130
157-
You can deploy changes to this app by using the same process and choosing the existing app rather than creating a new one.
131+
You can deploy changes to this app by making edits in VS Code, saving your files, and then using the same process as before only choosing the existing app rather than creating a new one.
158132
159133
## Viewing Logs
160134
161-
In this section, you learn how to view (or "tail") the logs from the running App Service app. Any calls to `console.log` in the app are displayed in the output window in Visual Studio Code.
135+
You can view log output (calls to `console.log`) from the app directly in the VS Code output window.
162136
163-
Find the app in the **AZURE APP SERVICE** explorer, right-click the app, and choose **View Streaming Logs**.
137+
1. In the **AZURE APP SERVICE** explorer, right-click the app node and choose **Start Streaming Logs**.
164138
165-
When prompted, choose to enable logging and restart the application. Once the app is restarted, the VS Code output window opens with a connection to the log stream.
139+
![Start Streaming Logs](containers/media/quickstart-nodejs/view-logs.png)
166140
167-
![View Streaming Logs](containers/media/quickstart-nodejs/view-logs.png)
141+
1. When prompted, choose to enable logging and restart the application. Once the app is restarted, the VS Code output window opens with a connection to the log stream.
168142
169-
![Enable Logging and Restart](containers/media/quickstart-nodejs/enable-restart.png)
143+
![Enable Logging and Restart](containers/media/quickstart-nodejs/enable-restart.png)
170144
171-
After a few seconds, you'll see a message indicating that you're connected to the log-streaming service. Refresh the page a few times to see more activity.
145+
1. After a few seconds, the output window shows a message indicating that you're connected to the log-streaming service. You can generate more output activity by refreshing the page in the browser.
172146

173-
```bash
174-
2019-09-20 20:37:39.574 INFO - Initiating warmup request to container msdocs-vscode-node_2_00ac292a for site msdocs-vscode-node
175-
2019-09-20 20:37:55.011 INFO - Waiting for response to warmup request for container msdocs-vscode-node_2_00ac292a. Elapsed time = 15.4373071 sec
176-
2019-09-20 20:38:08.233 INFO - Container msdocs-vscode-node_2_00ac292a for site msdocs-vscode-node initialized successfully and is ready to serve requests.
177-
2019-09-20T20:38:21 Startup Request, url: /Default.cshtml, method: GET, type: request, pid: 61,1,7, SCM_SKIP_SSL_VALIDATION: 0, SCM_BIN_PATH: /opt/Kudu/bin, ScmType: None
178-
```
147+
<pre>
148+
Connecting to log stream...
149+
2020-03-04T19:29:44 Welcome, you are now connected to log-streaming service. The default timeout is 2 hours.
150+
Change the timeout with the App Setting SCM_LOGSTREAM_TIMEOUT (in seconds).
151+
</pre>
179152

180153
> [!div class="nextstepaction"]
181154
> [I ran into an issue](https://www.research.net/r/PWZWZ52?tutorial=node-deployment-azure-app-service&step=tailing-logs)
16.7 KB
Loading
13.7 KB
Loading

0 commit comments

Comments
 (0)