You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cloud-services/cloud-services-nodejs-develop-deploy-express-app.md
+19-17Lines changed: 19 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
1
---
2
2
title: Build and deploy a Node.js Express app to Azure Cloud Services (classic)
3
-
description: Use this tutorial to create a new application using the Express module, which provides an MVC framework for creating Node.js web applications.
3
+
description: Use this tutorial to create a new application using the Express module, which provides a Model-View-Control (MVC) framework for creating Node.js web applications.
Node.js includes a minimal set of functionality in the core runtime.
18
-
Developers often use 3rd party modules to provide additional
19
-
functionality when developing a Node.js application. In this tutorial
20
-
you'll create a new application using the [Express](https://github.com/expressjs/express) module, which provides an MVC framework for creating Node.js web applications.
18
+
Developers often use non-Microsoft modules to provide more
19
+
functionality when developing a Node.js application. In this tutorial,
20
+
you create a new application using the [Express](https://github.com/expressjs/express) module, which provides a Model-View-Control framework for creating Node.js web applications.
21
21
22
-
A screenshot of the completed application is below:
22
+
The following screenshot shows the completed application:
23
23
24
24

25
25
@@ -40,9 +40,7 @@ Perform the following steps to create a new cloud service project named `express
40
40
```
41
41
42
42
> [!NOTE]
43
-
> By default, **Add-AzureNodeWebRole** uses an older version of Node.js. The **Set-AzureServiceProjectRole** statement above instructs Azure to use v0.10.21 of Node. Note the parameters are case-sensitive. You can verify the correct version of Node.js has been selected by checking the **engines** property in **WebRole1\package.json**.
44
-
>
45
-
>
43
+
> By default, **Add-AzureNodeWebRole** uses an older version of Node.js. The preceding **Set-AzureServiceProjectRole** line instructs Azure to use v0.10.21 of Node. Note the parameters are case-sensitive. You can verify the correct version of Node.js has been selected by checking the **engines** property in **WebRole1\package.json**.
46
44
47
45
## Install Express
48
46
1. Install the Express generator by issuing the following command:
@@ -51,40 +49,44 @@ Perform the following steps to create a new cloud service project named `express
The output of the npm commandshould look similar to the result below.
52
+
The following screenshot shows the output of the npm command. Your output should look similar.
55
53
56
54

55
+
57
56
2. Change directories to the **WebRole1** directory and use the express command to generate a new application:
58
57
59
58
```powershell
60
59
PS C:\node\expressapp\WebRole1> express
61
60
```
62
61
63
-
You'll be prompted to overwrite your earlier application. Enter **y** or **yes** to continue. Express will generate the app.js file and a folder structure for building your application.
62
+
To continue, enter **y** or **yes** when prompted to overwrite your earlier application. Express generates the app.js file and a folder structure for building your application.
64
63
65
64

66
-
3. To install additional dependencies defined in the package.json file,
65
+
66
+
3. To install the other dependencies defined in the package.json file,
67
67
enter the following command:
68
68
69
69
```powershell
70
70
PS C:\node\expressapp\WebRole1> npm install
71
71
```
72
72
73
73

74
-
4. Use the following command to copy the **bin/www** file to **server.js**. This is so the cloud service can find the entry point for this application.
74
+
75
+
4. Use the following command to copy the **bin/www** file to **server.js**. This step allows the cloud service to find the entry point for this application.
Once the deployment operation completes, your browser will open and display the web page.
135
+
Once the deployment operation completes, your browser opens and displays the web page.
134
136
135
137

A variety of tools and techniques are available for testing the performance of cloud services.
16
+
Various tools and techniques are available for testing the performance of cloud services.
17
17
When you publish a cloud service to Azure, you can have Visual Studio collect profiling
18
18
data and then analyze it locally, as described in [Profiling an Azure Application][1].
19
-
You can also use diagnostics to track a variety of performance
19
+
You can also use diagnostics to track numerous performance
20
20
counters, as described in [Using performance counters in Azure][2].
21
21
You might also want to profile your application locally in the compute emulator before deploying it to the cloud.
22
22
23
-
This article covers the CPU Sampling method of profiling, which can be done locally in the emulator. CPU sampling is a method of profiling that is not very intrusive. At a designated sampling interval, the profiler takes a snapshot of the call stack. The data is collected over a period of time, and shown in a report. This method of profiling tends to indicate where in a computationally intensive application most of the CPU work is being done. This gives you the opportunity to focus on the "hot path" where your application is spending the most time.
23
+
This article covers the CPU Sampling method of profiling, which can be done locally in the emulator. CPU sampling is a method of profiling that isn't intrusive. At a designated sampling interval, the profiler takes a snapshot of the call stack. The data is collected over a period of time, and shown in a report. This method of profiling tends to indicate where in a computationally intensive application most of the CPU work is being done, giving you the opportunity to focus on the "hot path" where your application is spending the most time.
24
24
25
-
## 1: Configure Visual Studio for profiling
26
-
First, there are a few Visual Studio configuration options that might be helpful when profiling. To make sense of the profiling reports, you'll need symbols (.pdb files) for your application and also symbols for system libraries. You'll want to make sure that you reference the available symbol servers. To do this, on the **Tools** menu in Visual Studio, choose **Options**, then choose **Debugging**, then **Symbols**. Make sure that Microsoft Symbol Servers is listed under **Symbol file (.pdb) locations**. You can also reference https://referencesource.microsoft.com/symbols, which might have additional symbol files.
25
+
## Configure Visual Studio for profiling
26
+
First, there are a few Visual Studio configuration options that might be helpful when profiling. To make sense of the profiling reports, you need symbols (.pdb files) for your application and also symbols for system libraries. Make sure you reference the available symbol servers; to do so, on the **Tools** menu in Visual Studio, choose **Options**, then choose **Debugging**, then **Symbols**. Make sure that Microsoft Symbol Servers is listed under **Symbol file (.pdb) locations**. You can also reference https://referencesource.microsoft.com/symbols, which might have more symbol files.
27
27
28
28
![Symbol options][4]
29
29
30
30
If desired, you can simplify the reports that the profiler generates by setting Just My Code. With Just My Code enabled, function call stacks are simplified so that calls entirely internal to libraries and the .NET Framework are hidden from the reports. On the **Tools** menu, choose **Options**. Then expand the **Performance Tools** node, and choose **General**. Select the checkbox for **Enable Just My Code for profiler reports**.
31
31
32
32
![Just My Code options][17]
33
33
34
-
You can use these instructions with an existing project or with a new project. If you create a new project to try the techniques described below, choose a C# **Azure Cloud Service** project, and select a **Web Role** and a **Worker Role**.
34
+
You can use these instructions with an existing project or with a new project. If you create a new project to try the following techniques, choose a C# **Azure Cloud Service** project, and select a **Web Role** and a **Worker Role**.
Build and run your cloud service locally without debugging (Ctrl+F5), with the solution configuration set to **Release**. This ensures that all files and folders are created for running the application locally, and ensures that all the emulators are started. Start the Compute Emulator UI from the taskbar to verify that your worker role is running.
71
+
Build and run your cloud service locally without debugging (Ctrl+F5), with the solution configuration set to **Release**. This setting ensures that all files and folders are created for running the application locally and that all the emulators are started. To verify that your worker role is running, start the Compute Emulator UI from the taskbar.
72
72
73
-
## 2: Attach to a process
73
+
## Attach to a process
74
74
Instead of profiling the application by starting it from the Visual Studio 2010 IDE, you must attach the profiler to a running process.
75
75
76
-
To attach the profiler to a process, on the **Analyze** menu, choose**Profiler** and **Attach/Detach**.
76
+
To attach the profiler to a process, go to the **Analyze** menu, select**Profiler**, and choose**Attach/Detach**.
77
77
78
78
![Attach profile option][6]
79
79
80
80
For a worker role, find the WaWorkerHost.exe process.
81
81
82
82
![WaWorkerHost process][7]
83
83
84
-
If your project folder is on a network drive, the profiler will ask you to provide another location to save the profiling reports.
84
+
If your project folder is on a network drive, the profiler asks you to provide another location to save the profiling reports.
85
85
86
86
You can also attach to a web role by attaching to WaIISHost.exe.
87
87
If there are multiple worker role processes in your application, you need to use the processID to distinguish them. You can query the processID programmatically by accessing the Process object. For example, if you add this code to the Run method of the RoleEntryPoint-derived class in a role, you can look at the
88
-
log in the Compute Emulator UI to know what process to connect to.
88
+
sign-in the Compute Emulator UI to know what process to connect to.
@@ -101,33 +101,33 @@ Open the worker role log console window in the Compute Emulator UI by clicking o
101
101
102
102
![View process ID][9]
103
103
104
-
One you've attached, perform the steps in your application's UI (if needed) to reproduce the scenario.
104
+
Once you attach, perform the steps in your application's UI (if needed) to reproduce the scenario.
105
105
106
106
When you want to stop profiling, choose the **Stop Profiling** link.
107
107
108
108
![Stop Profiling option][10]
109
109
110
-
## 3: View performance reports
110
+
## View performance reports
111
111
The performance report for your application is displayed.
112
112
113
113
At this point, the profiler stops executing, saves data in a .vsp file, and displays a report
114
114
that shows an analysis of this data.
115
115
116
116
![Profiler report][11]
117
117
118
-
If you see String.wstrcpy in the Hot Path, click on Just My Code to change the view to show user code only. If you see String.Concat, try pressing the Show All Code button.
118
+
If you see String.wstrcpy in the Hot Path, select on Just My Code to change the view to show user code only. If you see String.Concat, try pressing the **Show All Code** button.
119
119
120
120
You should see the Concatenate method and String.Concat taking up a large portion
121
121
of the execution time.
122
122
123
123
![Analysis of report][12]
124
124
125
-
If you added the string concatenation code in this article, you should see a warning in the Task List for this. You may also see a warning that there is an excessive amount of garbage collection, which is due to the number of strings that are created and disposed.
125
+
If you added the string concatenation code in this article, you should see a warning in the Task List for it. You may also see a warning that there's an excessive amount of garbage collection, which is due to the number of strings created and disposed.
126
126
127
127
![Performance warnings][14]
128
128
129
-
## 4: Make changes and compare performance
130
-
You can also compare the performance before and after a code change. Stop the running process, and edit the code to replace the string concatenation operation with the use of StringBuilder:
129
+
## Make changes and compare performance
130
+
You can also compare the performance before and after a code change. To replace the string concatenation operation with the use of StringBuilder, stop the running process and edit the code:
131
131
132
132
```csharp
133
133
publicstaticstringConcatenate(intnumber)
@@ -150,19 +150,19 @@ The reports highlight differences between the two runs.
150
150
151
151
![Comparison report][16]
152
152
153
-
Congratulations! You've gotten started with the profiler.
153
+
Congratulations! You got started with the profiler.
154
154
155
155
## Troubleshooting
156
-
* Make sure you are profiling a Release build and start without debugging.
157
-
* If the Attach/Detach option is not enabled on the Profiler menu, run the Performance Wizard.
156
+
* Make sure you profile a Release build and start without debugging.
157
+
* If the Attach/Detach option isn't enabled on the Profiler menu, run the Performance Wizard.
158
158
* Use the Compute Emulator UI to view the status of your application.
159
159
* If you have problems starting applications in the emulator, or attaching the profiler, shut down the compute emulator and restart it. If that doesn't solve the problem, try rebooting. This problem can occur if you use the Compute Emulator to suspend and remove running deployments.
160
-
* If you have used any of the profiling commands from the
161
-
command line, especially the global settings, make sure that VSPerfClrEnv /globaloff has been called and that VsPerfMon.exe has been shut down.
162
-
*If when sampling, you see the message "PRF0025: No data was collected," check that the process you attached to has CPU activity. Applications that are not doing any computational work might not produce any sampling data. It's also possible that the process exited before any sampling was done. Check to see that the Run method for a role that you are profiling does not terminate.
160
+
* If you used any of the profiling commands from the
161
+
command line, especially the global settings, make sure you call VSPerfClrEnv /globaloff and shut down VsPerfMon.exe.
162
+
*When sampling, you see the message "PRF0025: No data was collected," check the CPU activity of the process. Applications that aren't doing any computational work might not produce any sampling data. It's also possible that the process exited before any sampling was done. Check to see that the Run method for a role that you profile doesn't terminate.
163
163
164
164
## Next Steps
165
-
Instrumenting Azure binaries in the emulator is not supported in the Visual Studio profiler, but if you want to test memory allocation, you can choose that option when profiling. You can also choose concurrency profiling, which helps you determine whether threads are wasting time competing for locks, or tier interaction profiling, which helps you track down performance problems when interacting between tiers of an application, most frequently between the data tier and a worker role. You can view the database queries that your app generates and use the profiling data to improve your use of the database. For information about tier interaction profiling, see the blog post [Walkthrough: Using the Tier Interaction Profiler in Visual Studio Team System 2010][3].
165
+
Instrumenting Azure binaries in the emulator isn't supported in the Visual Studio profiler, but if you want to test memory allocation, you can choose that option when profiling. You can also choose concurrency profiling, which helps you determine whether threads are wasting time competing for locks, or tier interaction profiling, which helps you track down performance problems when interacting between tiers of an application, most frequently between the data tier and a worker role. You can view the database queries that your app generates and use the profiling data to improve your use of the database. For information about tier interaction profiling, see the blog post [Walkthrough: Using the Tier Interaction Profiler in Visual Studio Team System 2010][3].
0 commit comments