Skip to content

Instantly share code, notes, and snippets.

@thomd
Created June 7, 2021 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomd/a10573979624e59e5cb01d5b042d2aa0 to your computer and use it in GitHub Desktop.
Save thomd/a10573979624e59e5cb01d5b042d2aa0 to your computer and use it in GitHub Desktop.
Example of a Azure Virtual Machine Scale Set #azure #example
# cloud-config
package_upgrade: true
packages:
- nginx
- nodejs
- npm
write_files:
- owner: www-data:www-data
path: /etc/nginx/sites-available/default
content: |
server {
listen 80;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
- owner: azureuser:azureuser
path: /home/azureuser/myapp/index.js
content: |
var express = require('express')
var app = express()
var os = require('os');
app.get('/', function (req, res) {
res.send('<h1>Welcome to Azure VM Scale Set</h1> <h2>Hello World from host ' + os.hostname() + '! </h2>')
})
app.listen(3000, function () {
console.log('Hello world app listening on port 3000!')
})
runcmd:
- service nginx restart
- cd "/home/azureuser/myapp"
- npm init
- npm install express -y
- nodejs index.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment