|
| 1 | +--- |
| 2 | +layout: HubPage |
| 3 | +hide_bc: true |
| 4 | +title: Node.js Dev Center | Microsoft Docs |
| 5 | +description: Learn how to develop and deploy Node.js applications in the cloud with Azure. |
| 6 | +ms.topic: hub-page |
| 7 | +--- |
| 8 | + |
| 9 | + |
| 10 | +<div id="main" class="v2"> |
| 11 | + <div class="container"> |
| 12 | + <h1 style="text-align: center">Node.js Dev Center</h1> |
| 13 | + <p style="text-align: center">Build, deploy, and scale your Node.js applications on the Azure cloud.</p> |
| 14 | + |
| 15 | + <ul class="cardsM cols cols2"> |
| 16 | + <li style=" |
| 17 | + flex-basis: 180px; |
| 18 | + text-align: center; |
| 19 | + background-color: black; |
| 20 | + font: white; |
| 21 | + display: block; |
| 22 | + margin-left: auto; |
| 23 | + margin-top: 15px; |
| 24 | + margin-bottom: 25px; |
| 25 | + margin-right: 10px; |
| 26 | + |
| 27 | + "> |
| 28 | + <a class="card" href="https://azure.microsoft.com/en-us/try/app-service/web/?language=nodejs"> |
| 29 | + <br> |
| 30 | + <div class="cardText"> |
| 31 | + <h3 style=" |
| 32 | + color: white; |
| 33 | + font-size: large; |
| 34 | + ">Get started free ></h3> |
| 35 | + </div> |
| 36 | + </a> |
| 37 | + </li> |
| 38 | + |
| 39 | + <li style=" |
| 40 | + flex-basis: 180px; |
| 41 | + text-align: center; |
| 42 | + background-color: white; |
| 43 | + display: block; |
| 44 | + margin-right: auto; |
| 45 | + margin-top: 15px; |
| 46 | + margin-bottom: 25px; |
| 47 | + margin-left: 10px; |
| 48 | + "> |
| 49 | + <a class="card" href="https://code.visualstudio.com/docs/nodejs/nodejs-deployment"> |
| 50 | + <br> |
| 51 | + <div class="cardText"> |
| 52 | + <h3 style=" |
| 53 | + color: black; |
| 54 | + font-size: large; |
| 55 | + ">Documentation</h3> |
| 56 | + </div> |
| 57 | + </a> |
| 58 | + </li> |
| 59 | + </ul> |
| 60 | + <img src="media/azure-cli-output.png" style=" |
| 61 | + display: block; |
| 62 | + margin: auto; |
| 63 | + border-radius: 7px; |
| 64 | + width: 650px |
| 65 | + "> |
| 66 | + |
| 67 | + <h2 style="margin-top: 50px">Get started fast</h2> |
| 68 | + <ul class="cardsM cols cols3"> |
| 69 | + <li> |
| 70 | + <a class="card" href="https://code.visualstudio.com/tutorials/static-website/getting-started"> |
| 71 | + <img class="cardImage" role="presentation" alt="" src="https://docs.microsoft.com/azure/media/index/webapp.svg"> |
| 72 | + <div class="cardText"> |
| 73 | + <h3>Static site hosting</h3> |
| 74 | + <p>Host your SPA with Azure Storage</p> |
| 75 | + </div> |
| 76 | + </a> |
| 77 | + </li> |
| 78 | + <li> |
| 79 | + <a class="card" href="https://code.visualstudio.com/tutorials/app-service-extension/getting-started"> |
| 80 | + <img class="cardImage" role="presentation" alt="" src="https://docs.microsoft.com/media/logos/logo_vs-code.svg"> |
| 81 | + <div class="cardText"> |
| 82 | + <h3>Full stack hosting</h3> |
| 83 | + <p>Deploy Express apps with App Service</p> |
| 84 | + </div> |
| 85 | + </a> |
| 86 | + </li> |
| 87 | + <li> |
| 88 | + <a class="card" href="https://code.visualstudio.com/tutorials/docker-extension/getting-started"> |
| 89 | + <img class="cardImage" role="presentation" alt="" src="https://docs.microsoft.com/azure/media/index/ContainerInstances.svg"> |
| 90 | + <div class="cardText"> |
| 91 | + <h3>Container app hosting</h3> |
| 92 | + <p>Build and deploy Node microservices on Azure</p> |
| 93 | + </div> |
| 94 | + </a> |
| 95 | + </li> |
| 96 | + <li> |
| 97 | + <a class="card" href="https://code.visualstudio.com/tutorials/functions-extension/getting-started"> |
| 98 | + <img class="cardImage" role="presentation" alt="" src="https://docs.microsoft.com/azure/media/index/azurefunctions.svg"> |
| 99 | + <div class="cardText"> |
| 100 | + <h3>Serverless apps and APIs</h3> |
| 101 | + <p>Use Azure functions to go serverless</p> |
| 102 | + </div> |
| 103 | + </a> |
| 104 | + </li> |
| 105 | + <li> |
| 106 | + <a class="card" href="https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-node-node-getstarted"> |
| 107 | + <img class="cardImage" role="presentation" alt="" src="https://docs.microsoft.com/azure/media/index/IOT_edge_50.svg"> |
| 108 | + <div class="cardText"> |
| 109 | + <h3>Connect and manage IoT devices</h3> |
| 110 | + <p>Use Azure IoT Hub to manage thousands of devices</p> |
| 111 | + </div> |
| 112 | + </a> |
| 113 | + </li> |
| 114 | + <li> |
| 115 | + <a class="card" href="https://docs.microsoft.com/en-us/vsts/build-release/apps/cd/azure/azure-devops-project-nodejs?toc=%2Fvsts%2Fdeploy-azure%2Ftoc.json&bc=%2Fvsts%2Fdeploy-azure%2Fbreadcrumb%2Ftoc.json&view=vsts"> |
| 116 | + <img class="cardImage" role="presentation" alt="" src="https://docs.microsoft.com/media/logos/logo_vs-team-services.svg"> |
| 117 | + <div class="cardText"> |
| 118 | + <h3>Add CI/CD</h3> |
| 119 | + <p>Use CI/CD to automate your deployments</p> |
| 120 | + </div> |
| 121 | + </a> |
| 122 | + </li> |
| 123 | + </ul> |
| 124 | + |
| 125 | + <hr style="margin-top:80px; margin-bottom:50px;"> |
| 126 | + |
| 127 | + <h2 style="text-align: left;">npm modules for every job</h2> |
| 128 | + |
| 129 | + <ul class="pivots"> |
| 130 | + <li> |
| 131 | + <a href="#storage">Upload files to storage</a> |
| 132 | + <ul id="storage"> |
| 133 | + <li> |
| 134 | + <a href="#storage1"></a> |
| 135 | + <div id="storage1"> |
| 136 | + <div> |
| 137 | + <h3>Upload files to Azure Storage </h3> |
| 138 | + <h4>1. Download the Azure CLI (on Windows <a href="https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest"> get the MSI</a>) and login.</h4> |
| 139 | + <div class="codeHeader" data-bi-name="code-header"><span class="language">bash</span> |
| 140 | + </div> |
| 141 | + <pre><code class="lang-bash"> |
| 142 | +brew install azure-cli |
| 143 | +az login |
| 144 | +az group create --name MyResourceGroup --location "West US" |
| 145 | + </code></pre> |
| 146 | + |
| 147 | + <h4>2. Create a storage container.</h4> |
| 148 | + <div class="codeHeader" data-bi-name="code-header"><span class="language">bash</span> |
| 149 | + </div> |
| 150 | + <pre><code class="lang-bash"> |
| 151 | +az storage account create -n mystorageaccount12312 -g MyResourceGroup -l westus --sku Standard_LRS |
| 152 | +az storage account keys list -n mystorageaccount12312 -g MyResourceGroup --output table |
| 153 | +az storage container create --name my-container --public-access blob --account-name mystorageaccount12312 --account-key <account-key-from-step-4> |
| 154 | + </code></pre> |
| 155 | + |
| 156 | + <h4>3. Upload files using the Azure storage npm package.</h4> |
| 157 | + <div class="tabGroup" id="tabgroup_ErXr5hkbUU" data-bi-name="tab-group"> |
| 158 | + <!-- <ul role="tablist"> |
| 159 | + <li role="presentation"> |
| 160 | + <a href="#tabpanel_ErXr5hkbUU_javascript" role="tab" aria-controls="tabpanel_ErXr5hkbUU_javascript" data-tab="javascript" tabindex="0" aria-selected="true" data-bi-name="tab">JavaScript</a> |
| 161 | + </li> |
| 162 | + <li role="presentation"> |
| 163 | + <a href="#tabpanel_ErXr5hkbUU_typescript" role="tab" aria-controls="tabpanel_ErXr5hkbUU_typescript" data-tab="typescript" tabindex="-1" data-bi-name="tab" aria-selected="false">TypeScript</a> |
| 164 | + </li> |
| 165 | + </ul> --> |
| 166 | + <section id="tabpanel_ErXr5hkbUU_javascript" role="tabpanel" data-tab="javascript"> |
| 167 | + <div class="codeHeader" data-bi-name="code-header"><span class="language">JavaScript</span> |
| 168 | + </div> |
| 169 | + <pre><code class="lang-js"> |
| 170 | +<span class="hljs-keyword">let</span> storage = <span class="hljs-built_in">require</span>(<span class="hljs-string">'azure-storage'</span>); |
| 171 | +<span class="hljs-keyword">let</span> util = <span class="hljs-built_in">require</span>(<span class="hljs-string">'util'</span>); |
| 172 | + |
| 173 | +<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">main</span>(<span class="hljs-params"></span>) </span>{ |
| 174 | + <span class="hljs-keyword">const</span> containerName = <span class="hljs-string">"my-container"</span>; |
| 175 | + <span class="hljs-keyword">const</span> blobService = storage.createBlobService(<span class="hljs-string">"mystorageaccount1231"</span>, ACCOUNT_KEY); |
| 176 | + |
| 177 | + blobService.createBlockBlobFromLocalFile = util.promisify(blobService.createBlockBlobFromLocalFile); |
| 178 | + blobService.listBlobsSegmented = util.promisify(blobService.listBlobsSegmented); |
| 179 | + |
| 180 | + <span class="hljs-keyword">const</span> uploadResult = <span class="hljs-keyword">await</span> blobService.createBlockBlobFromLocalFile(containerName, <span class="hljs-string">"myFile.txt"</span>, <span class="hljs-string">"<FULL_FILE_PATH>"</span>); |
| 181 | + <span class="hljs-keyword">const</span> listResult = <span class="hljs-keyword">await</span> blobService.listBlobsSegmented(containerName, <span class="hljs-literal">null</span>); |
| 182 | +} |
| 183 | +main(); |
| 184 | + </code></pre> |
| 185 | + </section> |
| 186 | + <section id="tabpanel_ErXr5hkbUU_typescript" role="tabpanel" data-tab="typescript" hidden="hidden" aria-hidden="true"> |
| 187 | + <div class="codeHeader" data-bi-name="code-header"> |
| 188 | + <span class="language">TypeScript</span> |
| 189 | + </div> |
| 190 | + <pre><code class="lang-TypeScript"> |
| 191 | +<span class="hljs-keyword">import</span> { promisify } <span class="hljs-keyword">from</span> <span class="hljs-string">'bluebird'</span>; |
| 192 | +<span class="hljs-keyword">import</span> { createBlobService, BlobService, common } <span class="hljs-keyword">from</span> <span class="hljs-string">'azure-storage'</span>; |
| 193 | + |
| 194 | +<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">main</span>(<span class="hljs-params"></span>) </span>{ |
| 195 | + <span class="hljs-keyword">const</span> containerName = <span class="hljs-string">"my-container"</span>; |
| 196 | + <span class="hljs-keyword">const</span> blobService = createBlobService(<span class="hljs-string">"mystorageaccount1231"</span>, ACCOUNT_KEY); |
| 197 | + |
| 198 | + <span class="hljs-keyword">const</span> createBlockBlobFromLocalFileAsync = promisify(blobService.createBlockBlobFromLocalFile, {context: blobService}); |
| 199 | + <span class="hljs-keyword">const</span> listBlobsSegmentedAsync = promisify(blobService.listBlobsSegmented, {context: blobService}); |
| 200 | + |
| 201 | + <span class="hljs-keyword">const</span> uploadResult = <span class="hljs-keyword">await</span> createBlockBlobFromLocalFileAsync(containerName, <span class="hljs-string">"myFile.txt"</span>, <span class="hljs-string">"<FULL_FILE_PATH>"</span>); |
| 202 | + <span class="hljs-keyword">const</span> listResult = <span class="hljs-keyword">await</span> listBlobsSegmentedAsync(containerName, <span class="hljs-literal">null</span>); |
| 203 | +} |
| 204 | +main(); |
| 205 | + </code></pre> |
| 206 | + </section> |
| 207 | + </div> |
| 208 | + </div> |
| 209 | + </div> |
| 210 | + </li> |
| 211 | + </ul> |
| 212 | + </li> |
| 213 | + |
| 214 | + <li> |
| 215 | + <a href="#cogs">Sentiment analysis</a> |
| 216 | + <ul id="cogs"> |
| 217 | + <li> |
| 218 | + <a href="#cogs1">Text Analytics</a> |
| 219 | + <div id="cogs1" style="display: block"> |
| 220 | + <div> |
| 221 | + |
| 222 | + <h3>Get sentiment on any language. </h3> |
| 223 | + <h4>1. Download the Azure CLI (on Windows <a href="https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest"> get the MSI</a>) and login.</h4> |
| 224 | + <div class="codeHeader" data-bi-name="code-header"><span class="language">bash</span> |
| 225 | + </div> |
| 226 | + <pre><code class="lang-bash"> |
| 227 | +brew install azure-cli |
| 228 | +az login |
| 229 | +az group create --name MyResourceGroup --location "West US" |
| 230 | + </code></pre> |
| 231 | + |
| 232 | + <h4>2. Create a cognitive services text analytics account and retrieve your account key.</h4> |
| 233 | + <div class="codeHeader" data-bi-name="code-header"><span class="language">bash</span> |
| 234 | + </div> |
| 235 | + <pre><code class="lang-bash"> |
| 236 | +az cognitiveservices account create -n cogstest -g MyResourceGroup --sku S0 --kind TextAnalytics -l westcentralus |
| 237 | +az cognitiveservices account keys list -g MyResourceGroup -n cogstest |
| 238 | + </code></pre> |
| 239 | + |
| 240 | + <h4>3. Use the cognitive services API using your account key.</h4> |
| 241 | + <div class="tabGroup" id="tabgroup_ErXr5hkbUU" data-bi-name="tab-group"> |
| 242 | + <!-- <ul role="tablist"> |
| 243 | + <li role="presentation"> |
| 244 | + <a href="#tabpanel_ErXr5hkbUU_javascript" role="tab" aria-controls="tabpanel_ErXr5hkbUU_javascript" data-tab="javascript" tabindex="0" aria-selected="true" data-bi-name="tab">JavaScript</a> |
| 245 | + </li> |
| 246 | + <li role="presentation"> |
| 247 | + <a href="#tabpanel_ErXr5hkbUU_typescript" role="tab" aria-controls="tabpanel_ErXr5hkbUU_typescript" data-tab="typescript" tabindex="-1" data-bi-name="tab" aria-selected="false">TypeScript</a> |
| 248 | + </li> |
| 249 | + </ul> --> |
| 250 | + <section id="tabpanel_ErXr5hkbUU_javascript" role="tabpanel" data-tab="javascript"> |
| 251 | + <div class="codeHeader" data-bi-name="code-header"><span class="language">JavaScript</span> |
| 252 | + </div> |
| 253 | + <pre><code class="lang-js"> |
| 254 | +<span class="hljs-keyword">let</span> https = <span class="hljs-built_in">require</span>(<span class="hljs-string">"https"</span>); |
| 255 | + |
| 256 | +<span class="hljs-keyword">let</span> request_params = { |
| 257 | + <span class="hljs-attr">method</span>: <span class="hljs-string">"POST"</span>, |
| 258 | + <span class="hljs-attr">hostname</span>: <span class="hljs-string">"westcentralus.api.cognitive.microsoft.com"</span>, |
| 259 | + <span class="hljs-attr">path</span>: <span class="hljs-string">"/text/analytics/v2.0/sentiment"</span>, |
| 260 | + <span class="hljs-attr">headers</span>: { |
| 261 | + <span class="hljs-string">"Ocp-Apim-Subscription-Key"</span>: ACCOUNT_KEY, |
| 262 | + } |
| 263 | +}; |
| 264 | + |
| 265 | +<span class="hljs-keyword">let</span> getTextAnalytics = https.request(request_params, <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">response</span>) </span>{ |
| 266 | + <span class="hljs-keyword">let</span> body = <span class="hljs-string">""</span>; |
| 267 | + response.on(<span class="hljs-string">"data"</span>, <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">d</span>) </span>{ |
| 268 | + body += d; |
| 269 | + }); |
| 270 | + response.on(<span class="hljs-string">"end"</span>, <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{ |
| 271 | + <span class="hljs-keyword">let</span> body_ = <span class="hljs-built_in">JSON</span>.parse(body); |
| 272 | + <span class="hljs-keyword">let</span> body__ = <span class="hljs-built_in">JSON</span>.stringify(body_, <span class="hljs-literal">null</span>, <span class="hljs-string">" "</span>); |
| 273 | + <span class="hljs-built_in">console</span>.log(body__); |
| 274 | + }); |
| 275 | + response.on(<span class="hljs-string">"error"</span>, <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">e</span>) </span>{ |
| 276 | + <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Error: "</span> + e.message); |
| 277 | + }); |
| 278 | +}); |
| 279 | + |
| 280 | +<span class="hljs-keyword">let</span> body = <span class="hljs-built_in">JSON</span>.stringify({ |
| 281 | + <span class="hljs-string">"documents"</span>: [ |
| 282 | + { <span class="hljs-string">"id"</span>: <span class="hljs-string">"1"</span>, <span class="hljs-string">"language"</span>: <span class="hljs-string">"en"</span>, <span class="hljs-string">"text"</span>: <span class="hljs-string">"Node.js and Azure are awesome!"</span> }, |
| 283 | + { <span class="hljs-string">"id"</span>: <span class="hljs-string">"2"</span>, <span class="hljs-string">"language"</span>: <span class="hljs-string">"es"</span>, <span class="hljs-string">"text"</span>: <span class="hljs-string">"Este ha sido un dia terrible."</span> }, |
| 284 | + ] |
| 285 | +}); |
| 286 | + |
| 287 | +getTextAnalytics.write(body); |
| 288 | +getTextAnalytics.end(); |
| 289 | + </code></pre> |
| 290 | + </section> |
| 291 | + <section id="tabpanel_ErXr5hkbUU_typescript" role="tabpanel" data-tab="typescript" hidden="hidden" aria-hidden="true"> |
| 292 | + <div class="codeHeader" data-bi-name="code-header"> |
| 293 | + <span class="language">TypeScript</span> |
| 294 | + </div> |
| 295 | + <pre><code class="lang-TypeScript"> |
| 296 | +// TODO |
| 297 | + </code></pre> |
| 298 | + </section> |
| 299 | + </div> |
| 300 | + </div> |
| 301 | + </div> |
| 302 | + </li> |
| 303 | + </ul> |
| 304 | + </li> |
| 305 | + </ul> |
| 306 | + |
| 307 | + <ul class="cardsM cols cols2"> |
| 308 | + <li style=" |
| 309 | + flex-basis: 180px; |
| 310 | + text-align: center; |
| 311 | + background-color: black; |
| 312 | + font: white; |
| 313 | + display: block; |
| 314 | + margin-left: auto; |
| 315 | + margin-top: 15px; |
| 316 | + margin-bottom: 25px; |
| 317 | + margin-right: 10px; |
| 318 | + |
| 319 | + "> |
| 320 | + <a class="card" href="https://azure.microsoft.com/en-us/try/app-service/web/?language=nodejs"> |
| 321 | + <br> |
| 322 | + <div class="cardText"> |
| 323 | + <h3 style=" |
| 324 | + color: white; |
| 325 | + font-size: large; |
| 326 | + ">Get started free ></h3> |
| 327 | + </div> |
| 328 | + </a> |
| 329 | + </li> |
| 330 | + |
| 331 | + <li style=" |
| 332 | + flex-basis: 180px; |
| 333 | + text-align: center; |
| 334 | + background-color: white; |
| 335 | + display: block; |
| 336 | + margin-right: auto; |
| 337 | + margin-top: 15px; |
| 338 | + margin-bottom: 25px; |
| 339 | + margin-left: 10px; |
| 340 | + "> |
| 341 | + <a class="card" href="https://docs.microsoft.com/en-us/javascript/api/overview/azure/?view=azure-node-latest"> |
| 342 | + <br> |
| 343 | + <div class="cardText"> |
| 344 | + <h3 style=" |
| 345 | + color: black; |
| 346 | + font-size: large; |
| 347 | + ">API Reference</h3> |
| 348 | + </div> |
| 349 | + </a> |
| 350 | + </li> |
| 351 | + </ul> |
| 352 | + </div> |
| 353 | + |
| 354 | +</div> |
0 commit comments