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
A cloud service is created from three components, the service definition *(.csdef)*, the service config *(.cscfg)*, and a service package *(.cspkg)*. Both the **ServiceDefinition.csdef** and **ServiceConfig.cscfg** files are XML-based and describe the structure of the cloud service and how it's configured; collectively called the model. The **ServicePackage.cspkg** is a zip file that is generated from the **ServiceDefinition.csdef** and among other things, contains all the required binary-based dependencies. Azure creates a cloud service from both the **ServicePackage.cspkg** and the **ServiceConfig.cscfg**.
18
+
A cloud service is created from three components, the service definition *(.csdef)*, the service config *(.cscfg)*, and a service package *(.cspkg)*. Both the **ServiceDefinition.csdef** and **ServiceConfig.cscfg** files are XML-based and describe the structure of the cloud service and its configuration; collectively called the model. The **ServicePackage.cspkg** is a zip file that is generated from the **ServiceDefinition.csdef** and among other things, contains all the required binary-based dependencies. Azure creates a cloud service from both the **ServicePackage.cspkg** and the **ServiceConfig.cscfg**.
19
19
20
-
Once the cloud service is running in Azure, you can reconfigure it through the **ServiceConfig.cscfg** file, but you cannot alter the definition.
20
+
Once the cloud service is running in Azure, you can reconfigure it through the **ServiceConfig.cscfg** file, but you can't alter the definition.
21
21
22
22
## What would you like to know more about?
23
23
* I want to know more about the [ServiceDefinition.csdef](#csdef) and [ServiceConfig.cscfg](#cscfg) files.
24
24
* I already know about that, give me [some examples](#next-steps) on what I can configure.
25
25
* I want to create the [ServicePackage.cspkg](#cspkg).
26
-
* I am using Visual Studio and I want to...
26
+
* I'm using Visual Studio and I want to...
27
27
*[Create a cloud service][vs_create]
28
28
*[Reconfigure an existing cloud service][vs_reconfigure]
29
29
*[Deploy a Cloud Service project][vs_deploy]
@@ -83,7 +83,7 @@ The **ServiceDefinition.csdef** file specifies the settings that are used by Azu
83
83
</ServiceDefinition>
84
84
```
85
85
86
-
You can refer to the [Service Definition Schema](/previous-versions/azure/reference/ee758711(v=azure.100)) for a better understanding of the XML schema used here, however, here is a quick explanation of some of the elements:
86
+
You can refer to the [Service Definition Schema](/previous-versions/azure/reference/ee758711(v=azure.100)) for a better understanding of the XML schema used here, however, here's a quick explanation of some of the elements:
87
87
88
88
**Sites**
89
89
Contains the definitions for websites or web applications that are hosted in IIS7.
@@ -114,7 +114,7 @@ Contains tasks that are run when the role starts. The tasks are defined in a .cm
114
114
## ServiceConfiguration.cscfg
115
115
The configuration of the settings for your cloud service is determined by the values in the **ServiceConfiguration.cscfg** file. You specify the number of instances that you want to deploy for each role in this file. The values for the configuration settings that you defined in the service definition file are added to the service configuration file. The thumbprints for any management certificates that are associated with the cloud service are also added to the file. The [Azure Service Configuration Schema (.cscfg File)](/previous-versions/azure/reference/ee758710(v=azure.100)) provides the allowable format for a service configuration file.
116
116
117
-
The service configuration file is not packaged with the application, but is uploaded to Azure as a separate file and is used to configure the cloud service. You can upload a new service configuration file without redeploying your cloud service. The configuration values for the cloud service can be changed while the cloud service is running. The following example shows the configuration settings that can be defined for the Web and Worker roles:
117
+
The service configuration file isn't packaged with the application. The configuration uploads to Azure as a separate file and used to configure the cloud service. You can upload a new service configuration file without redeploying your cloud service. The configuration values for the cloud service can be changed while the cloud service is running. The following example shows the configuration settings that can be defined for the Web and Worker roles:
118
118
119
119
```xml
120
120
<?xml version="1.0"?>
@@ -134,10 +134,10 @@ The service configuration file is not packaged with the application, but is uplo
134
134
</ServiceConfiguration>
135
135
```
136
136
137
-
You can refer to the [Service Configuration Schema](/previous-versions/azure/reference/ee758710(v=azure.100)) for better understanding the XML schema used here, however, here is a quick explanation of the elements:
137
+
You can refer to the [Service Configuration Schema](/previous-versions/azure/reference/ee758710(v=azure.100)) for better understanding the XML schema used here, however, here's a quick explanation of the elements:
138
138
139
139
**Instances**
140
-
Configures the number of running instances for the role. To prevent your cloud service from potentially becoming unavailable during upgrades, it is recommended that you deploy more than one instance of your web-facing roles. By deploying more than one instance, you are adhering to the guidelines in the [Azure Compute Service Level Agreement (SLA)](https://azure.microsoft.com/support/legal/sla/), which guarantees 99.95% external connectivity for Internet-facing roles when two or more role instances are deployed for a service.
140
+
Configures the number of running instances for the role. To prevent your cloud service from potentially becoming unavailable during upgrades, we recommend you deploy more than one instance of your web-facing roles. By deploying more than one instance, you adhere to the guidelines in the [Azure Compute Service Level Agreement (SLA)](https://azure.microsoft.com/support/legal/sla/), which guarantees 99.95% external connectivity for Internet-facing roles when two or more role instances are deployed for a service.
141
141
142
142
**ConfigurationSettings**
143
143
Configures the settings for the running instances for a role. The name of the `<Setting>` elements must match the setting definitions in the service definition file.
@@ -155,7 +155,7 @@ Configures the certificates that are used by the service. The previous code exam
155
155
## Defining ports for role instances
156
156
Azure allows only one entry point to a web role. Meaning that all traffic occurs through one IP address. You can configure your websites to share a port by configuring the host header to direct the request to the correct location. You can also configure your applications to listen to well-known ports on the IP address.
157
157
158
-
The following sample shows the configuration for a web role with a website and web application. The website is configured as the default entry location on port 80, and the web applications are configured to receive requests from an alternate host header that is called “mail.mysite.cloudapp.net”.
158
+
The following sample shows the configuration for a web role with a website and web application. The website is configured as the default entry location on port 80. The web applications are configured to receive requests from an alternate host header that is called “mail.mysite.cloudapp.net”.
159
159
160
160
```xml
161
161
<WebRole>
@@ -191,14 +191,14 @@ The following sample shows the configuration for a web role with a website and w
191
191
192
192
193
193
## Changing the configuration of a role
194
-
You can update the configuration of your cloud service while it is running in Azure, without taking the service offline. To change configuration information, you can either upload a new configuration file, or edit the configuration file in place and apply it to your running service. The following changes can be made to the configuration of a service:
194
+
You can update the configuration of your cloud service while it runs in Azure, without taking the service offline. To change configuration information, you can either upload a new configuration file, or edit the configuration file in place and apply it to your running service. The following changes can be made to the configuration of a service:
195
195
196
196
***Changing the values of configuration settings**
197
197
When a configuration setting changes, a role instance can choose to apply the change while the instance is online, or to recycle the instance gracefully and apply the change while the instance is offline.
198
198
***Changing the service topology of role instances**
199
-
Topology changes do not affect running instances, except where an instance is being removed. All remaining instances generally do not need to be recycled; however, you can choose to recycle role instances in response to a topology change.
199
+
Topology changes don't affect running instances, except where an instance is being removed. All remaining instances generally don't need to be recycled; however, you can choose to recycle role instances in response to a topology change.
200
200
***Changing the certificate thumbprint**
201
-
You can only update a certificate when a role instance is offline. If a certificate is added, deleted, or changed while a role instance is online, Azure gracefully takes the instance offline to update the certificate and bring it back online after the change is complete.
201
+
You can only update a certificate when a role instance is offline. If a certificate is added, deleted, or changed while a role instance is online, Azure gracefully takes the instance offline to update the certificate. Azure brings it back online after the change is complete.
202
202
203
203
### Handling configuration changes with Service Runtime Events
204
204
The [Azure Runtime Library](/previous-versions/azure/reference/mt419365(v=azure.100)) includes the [Microsoft.WindowsAzure.ServiceRuntime](/previous-versions/azure/reference/ee741722(v=azure.100)) namespace, which provides classes for interacting with the Azure environment from a role. The [RoleEnvironment](/previous-versions/azure/reference/ee773173(v=azure.100)) class defines the following events that are raised before and after a configuration change:
@@ -266,7 +266,7 @@ Where the variables are defined as follows:
266
266
| --- | --- |
267
267
|\[DirectoryName\]|The subdirectory under the root project directory that contains the .csdef file of the Azure project. |
268
268
|\[ServiceDefinition\]|The name of the service definition file. By default, this file is named ServiceDefinition.csdef. |
269
-
|\[OutputFileName\]|The name for the generated package file. Typically, this is set to the name of the application. If no file name is specified, the application package is created as \[ApplicationName\].cspkg. |
269
+
|\[OutputFileName\]|The name for the generated package file. Typically, this variable is set to the name of the application. If no file name is specified, the application package is created as \[ApplicationName\].cspkg. |
270
270
|\[RoleName\]|The name of the role as defined in the service definition file. |
271
271
|\[RoleBinariesDirectory]|The location of the binary files for the role. |
272
272
|\[VirtualPath\]|The physical directories for each virtual path defined in the Sites section of the service definition. |
@@ -279,7 +279,7 @@ I'm creating a cloud service package and I want to...
279
279
*[Setup remote desktop for a cloud service instance][remotedesktop]
280
280
*[Deploy a Cloud Service project][deploy]
281
281
282
-
I am using Visual Studio and I want to...
282
+
I'm using Visual Studio and I want to...
283
283
284
284
*[Create a new cloud service][vs_create]
285
285
*[Reconfigure an existing cloud service][vs_reconfigure]
description: Socket.IO is now natively supported on Azure. This old tutorial shows how to self-host a socket.IO-based chat application on Azure. The latest recommendation is to let Socket.IO provide real time communication for a Node.js server and clients, and let Azure manage scaling client connections.
4
4
ms.topic: article
5
5
ms.service: cloud-services
6
-
ms.date: 08/31/2023
6
+
ms.date: 07/23/2024
7
7
author: hirenshah1
8
8
ms.author: hirshah
9
9
ms.reviewer: mimckitt
@@ -23,7 +23,7 @@ server and clients. This tutorial walks you through hosting a
23
23
socket.IO based chat application on Azure. For more information
24
24
on Socket.IO, see [socket.io](https://socket.io).
25
25
26
-
A screenshot of the completed application is below:
26
+
The following screenshot shows the completed application:
27
27
28
28
![A browser window displaying the service hosted on Azure][completed-app]
29
29
@@ -35,7 +35,7 @@ Ensure that the following products and versions are installed to successfully co
35
35
* Install [Python version 2.7.10](https://www.python.org/)
36
36
37
37
## Create a Cloud Service Project
38
-
The following steps create the cloud service project that will host the Socket.IO application.
38
+
The following steps create the cloud service project that hosts the Socket.IO application.
39
39
40
40
1. From the **Start Menu** or **Start Screen**, search for **Windows PowerShell**. Finally, right-click **Windows PowerShell** and select **Run As Administrator**.
41
41
@@ -60,13 +60,13 @@ The following steps create the cloud service project that will host the Socket.I
60
60
PS C:\Node> Add-AzureNodeWorkerRole
61
61
```
62
62
63
-
You will see the following response:
63
+
You see the following response:
64
64
65
65

66
66
67
67
## Download the Chat Example
68
68
69
-
For this project, we will use the chat example from the [Socket.IO
69
+
For this project, we use the chat example from the [Socket.IO
70
70
GitHub repository]. Perform the following steps to download the example
71
71
and add it to the project you previously created.
72
72
@@ -80,9 +80,9 @@ and add it to the project you previously created.
80
80
81
81
![Explorer, displaying the contents of the examples\\chat directory extracted from the archive][chat-contents]
82
82
83
-
The highlighted items in the screenshot above are the files copied from the **examples\\chat** directory
83
+
The highlighted items in the previous screenshot are the files copied from the **examples\\chat** directory
84
84
85
-
3. In the **C:\\node\\chatapp\\WorkerRole1** directory, delete the **server.js** file, and then rename the **app.js** file to **server.js**. This removes the default **server.js** file created previously by the **Add-AzureNodeWorkerRole** cmdlet and replaces it with the application file from the chat example.
85
+
3. In the **C:\\node\\chatapp\\WorkerRole1** directory, delete the **server.js** file, and then rename the **app.js** file to **server.js**. This step removes the default **server.js** file created previously by the **Add-AzureNodeWorkerRole** cmdlet and replaces it with the application file from the chat example.
86
86
87
87
### Modify Server.js and Install Modules
88
88
Before testing the application in the Azure emulator, we must
@@ -91,7 +91,7 @@ server.js file:
91
91
92
92
1. Open the **server.js** file in Visual Studio or any text editor.
93
93
94
-
2. Find the **Module dependencies** section at the beginning of server.js and change the line containing **sio = require('..//..//lib//socket.io')** to **sio = require('socket.io')** as shown below:
94
+
2. Find the **Module dependencies** section at the beginning of server.js and change the line containing **sio = require('..//..//lib//socket.io')** to **sio = require('socket.io')** as follows:
95
95
96
96
```js
97
97
var express = require('express')
@@ -104,7 +104,7 @@ server.js file:
104
104
105
105
3. To ensure the application listens on the correct port, open
106
106
server.js in Notepad or your favorite editor, and then change the
107
-
following line by replacing **3000** with **process.env.port** as shown below:
107
+
following line by replacing **3000** with **process.env.port** as follows:
108
108
109
109
```js
110
110
//app.listen(3000, function () { //Original
@@ -118,21 +118,21 @@ After saving the changes to **server.js**, use the following steps to
118
118
install required modules, and then test the application in the
119
119
Azure emulator:
120
120
121
-
1. Using **Azure PowerShell**, change directories to the **C:\\node\\chatapp\\WorkerRole1** directory and use the following command to install the modules required by this application:
121
+
1. In **Azure PowerShell**, change directories to the **C:\\node\\chatapp\\WorkerRole1** directory and use the following command to install the modules required by this application:
122
122
123
123
```powershell
124
124
PS C:\node\chatapp\WorkerRole1> npm install
125
125
```
126
126
127
-
This will install the modules listed in the package.json file. After
127
+
This command installs the modules listed in the package.json file. After
128
128
the command completes, you should see output similar to the
129
-
following:
129
+
following screenshot:
130
130
131
131
![The output of the npm install command][The-output-of-the-npm-install-command]
132
132
133
133
2. Since this example was originally a part of the Socket.IO GitHub
134
134
repository, and directly referenced the Socket.IO library by
135
-
relative path, Socket.IO was not referenced in the package.json
135
+
relative path, Socket.IO wasn't referenced in the package.json
136
136
file, so we must install it by issuing the following command:
137
137
138
138
```powershell
@@ -156,8 +156,8 @@ Azure emulator:
156
156
2. Open a browser and navigate to `http://127.0.0.1`.
157
157
158
158
3. When the browser window opens, enter a nickname and then hit enter.
159
-
This will allow you to post messages as a specific nickname. To test
160
-
multi-user functionality, open additional browser windows using the
159
+
This step allows you to post messages as a specific nickname. To test
160
+
multi-user functionality, open more browser windows using the
161
161
same URL and enter different nicknames.
162
162
163
163

@@ -193,7 +193,7 @@ messages between different clients using Socket.IO.
193
193
194
194
## Next steps
195
195
196
-
In this tutorial you learned how to create a basic chat application hosted in an Azure Cloud Service. To learn how to host this application in an Azure Website, see [Build a Node.js Chat Application with Socket.IO on an Azure Web Site][chatwebsite].
196
+
In this tutorial, you learned how to create a basic chat application hosted in an Azure Cloud Service. To learn how to host this application in an Azure Website, see [Build a Node.js Chat Application with Socket.IO on an Azure Web Site][chatwebsite].
197
197
198
198
For more information, see also the [Node.js Developer Center](/azure/developer/javascript/).
0 commit comments