• Azure 深入浅出[2] --- App Service的部署并查看应用Log


    假设读者已经申请了Azure的免费订阅的账户。如果想部署一个前端NodeJS的服务到Azure的App Service应该如何部署并查看应用程序本身的日志呢?笔者在这边文章就带大家快速看一下。

    1.环境准备

    安装Visual Studio Code以及在Visual Studio Code里面安装Azure App Service插件。
    在这里插入图片描述

    2.新建一个NodeJS的项目

    新建一个NodeJs的项目,其目录结果如下
    在这里插入图片描述
    2.1 app.js

    var createError = require('http-errors');
    var express = require('express');
    var path = require('path');
    var cookieParser = require('cookie-parser');
    var logger = require('morgan');
    
    var indexRouter = require('./routes/index');
    var usersRouter = require('./routes/users');
    
    var app = express();
    
    // view engine setup
    app.set('views', path.join(__dirname, 'views'));
    app.set('view engine', 'ejs');
    
    app.use(logger('dev'));
    app.use(express.json());
    app.use(express.urlencoded({ extended: false }));
    app.use(cookieParser());
    app.use(express.static(path.join(__dirname, 'public')));
    
    app.use('/', indexRouter);
    app.use('/users', usersRouter);
    
    // catch 404 and forward to error handler
    app.use(function(req, res, next) {
      next(createError(404));
    });
    
    // error handler
    app.use(function(err, req, res, next) {
      // set locals, only providing error in development
      res.locals.message = err.message;
      res.locals.error = req.app.get('env') === 'development' ? err : {};
    
      // render the error page
      res.status(err.status || 500);
      res.render('error');
    });
    
    module.exports = app;
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41

    2.2 package.json

    {
      "name": "myexpressapp",
      "version": "0.0.0",
      "private": true,
      "scripts": {
        "start": "node ./bin/www"
      },
      "dependencies": {
        "cookie-parser": "~1.4.4",
        "debug": "~2.6.9",
        "ejs": "~2.6.1",
        "express": "~4.16.1",
        "http-errors": "~1.6.3",
        "morgan": "~1.9.1"
      }
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    2.3 index.ejs

    <!DOCTYPE html>
    <html>
      <head>
        <title>Welcome to Azure 1111</title>
        <link rel='stylesheet' href='/stylesheets/style.css' />
      </head>
      <body>
        <h1><%= title %></h1>
        <p>Welcome to <%= title %></p>
      </body>
    </html>
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    2.4 index.js

    var express = require('express');
    var router = express.Router();
    
    /* GET home page. */
    router.get('/', function(req, res, next) {
      res.render('index', { title: 'Express' });
    });
    
    module.exports = router;
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    3.登录并发布应用到AppService

    打开Azure App Service的插件,并选择你的应用,并点击右键进行部署。
    在这里插入图片描述

    4.发布成功后,查看App Service的应用

    打开浏览器,就可以看到你在Azure的App Service发布的App的了
    https://xxxxx-yyyyy-nn.azurewebsites.net/
    在这里插入图片描述

    如果用azure CLI执行同样的部署,则部署命令如下:

    SUBSCRIPTION="免费试用"
    RESOURCEGROUP="xxxxxx-rg"
    LOCATION="eastus"
    PLANNAME="xxxxxx-plan"
    PLANSKU="F1"
    SITENAME="xxxxxx
    RUNTIME="NODE|18-lts"
    
    # login supports device login, username/password, and service principals
    # see https://docs.microsoft.com/en-us/cli/azure/?view=azure-cli-latest#az_login
    az login
    # list all of the available subscriptions
    az account list -o table
    # set the default subscription for subsequent operations
    az account set --subscription $SUBSCRIPTION
    # create a resource group for your application
    az group create --name $RESOURCEGROUP --location $LOCATION
    # create an appservice plan (a machine) where your site will run
    az appservice plan create --name $PLANNAME --location $LOCATION --is-linux --sku $PLANSKU --resource-group $RESOURCEGROUP
    # create the web application on the plan
    # specify the node version your app requires
    az webapp create --name $SITENAME --plan $PLANNAME --runtime $RUNTIME --resource-group $RESOURCEGROUP
    
    # To set up deployment from a local git repository, uncomment the following commands.
    # first, set the username and password (use environment variables!)
    # USERNAME=""
    # PASSWORD=""
    # az webapp deployment user set --user-name $USERNAME --password $PASSWORD
    
    # now, configure the site for deployment. in this case, we will deploy from the local git repository
    # you can also configure your site to be deployed from a remote git repository or set up a CI/CD workflow
    # az webapp deployment source config-local-git --name $SITENAME --resource-group $RESOURCEGROUP
    
    # the previous command returned the git remote to deploy to
    # use this to set up a new remote named "azure"
    # git remote add azure "https://$USERNAME@$SITENAME.scm.azurewebsites.net/$SITENAME.git"
    # push master to deploy the site
    # git push azure master
    
    # browse to the site
    # az webapp browse --name $SITENAME --resource-group $RESOURCEGROUP
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42

    部署后,其Log如下:

    23:09:20 xxxxx-01: Starting deployment...
    23:09:26 xxxxx-01: Creating zip package...
    23:09:29 xxxxx-01: Zip package size: 699 kB
    23:09:36: Error: request to https://xxxxx-01.scm.azurewebsites.net/api/deployments/latest?deployer=Push-Deployer&time=2022-11-20_15-09-29Z failed, reason: Client network socket disconnected before secure TLS connection was established
    23:11:56 xxxxx-01: Starting deployment...
    23:12:03 xxxxx-01: Creating zip package...
    23:12:04 xxxxx-01: Zip package size: 699 kB
    23:12:09 xxxxx-01: Fetching changes.
    23:12:10 xxxxx-01: Cleaning up temp folders from previous zip deployments and extracting pushed zip file /tmp/zipdeploy/27046216-ca9d-45e5-957c-89645f86ecda.zip (0.68 MB) to /tmp/zipdeploy/extracted
    23:12:17 xxxxx-01: Updating submodules.
    23:12:19 xxxxx-01: Preparing deployment for commit id '7a23d334-b'.
    23:12:19 xxxxx-01: PreDeployment: context.CleanOutputPath False
    23:12:19 xxxxx-01: PreDeployment: context.OutputPath /home/site/wwwroot
    23:12:20 xxxxx-01: Repository path is /tmp/zipdeploy/extracted
    23:12:20 xxxxx-01: Running oryx build...
    23:12:20 xxxxx-01: Command: oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform nodejs --platform-version 18 -p virtualenv_name= --log-file /tmp/build-debug.log  -i /tmp/8dacb099e11e089 -p compress_node_modules=tar-gz | tee /tmp/oryx-build.log
    23:12:25 xxxxx-01: Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
    23:12:26 xxxxx-01: You can report issues at https://github.com/Microsoft/Oryx/issues
    23:12:26 xxxxx-01: Oryx Version: 0.2.20220825.1, Commit: 24032445dbf7bf6ef068688f1b123a7144453b7f, ReleaseTagName: 20220825.1
    23:12:26 xxxxx-01: Build Operation ID: |GEQyjIHtYOs=.77ba5015_
    23:12:26 xxxxx-01: Repository Commit : 7a23d334-b04b-49a2-8064-033140072ee1
    23:12:26 xxxxx-01: Detecting platforms...
    23:12:32 xxxxx-01: Detected following platforms:
    23:12:32 xxxxx-01:   nodejs: 18.12.0
    23:12:33 xxxxx-01: Detected the following frameworks: Express
    23:12:34 xxxxx-01: Using intermediate directory '/tmp/8dacb099e11e089'.
    23:12:34 xxxxx-01: Copying files to the intermediate directory...
    23:12:38 xxxxx-01: Done in 4 sec(s).
    23:12:38 xxxxx-01: Source directory     : /tmp/8dacb099e11e089
    23:12:38 xxxxx-01: Destination directory: /home/site/wwwroot
    23:12:41 xxxxx-01: Removing existing manifest file
    23:12:41 xxxxx-01: Creating directory for command manifest file if it does not exist
    23:12:41 xxxxx-01: Creating a manifest file...
    23:12:41 xxxxx-01: Node Build Command Manifest file created.
    23:12:41 xxxxx-01: Using Node version:
    23:12:44 xxxxx-01: v18.12.0
    23:12:44 xxxxx-01: Using Npm version:
    23:13:04 xxxxx-01: 8.19.2
    23:13:04 xxxxx-01: Running 'npm install --unsafe-perm'...
    23:13:07 xxxxx-01: npm WARN old lockfile 
    23:13:08 xxxxx-01: npm WARN old lockfile The package-lock.json file was created with an old version of npm,
    23:13:08 xxxxx-01: npm WARN old lockfile so supplemental metadata must be fetched from the registry.
    23:13:08 xxxxx-01: npm WARN old lockfile 
    23:13:08 xxxxx-01: npm WARN old lockfile This is a one-time fix-up, please be patient...
    23:13:08 xxxxx-01: npm WARN old lockfile 
    23:13:15 xxxxx-01: added 54 packages, and audited 55 packages in 9s
    23:13:15 xxxxx-01: 1 critical severity vulnerability
    23:13:15 xxxxx-01: To address all issues (including breaking changes), run:
    23:13:15 xxxxx-01:   npm audit fix --force
    23:13:15 xxxxx-01: Run `npm audit` for details.
    23:13:15 xxxxx-01: Zipping existing node_modules folder...
    23:13:16 xxxxx-01: Done in 1 sec(s).
    23:13:16 xxxxx-01: Preparing output...
    23:13:16 xxxxx-01: Copying files to destination directory '/home/site/wwwroot'...
    23:13:16 xxxxx-01: Done in 0 sec(s).
    23:13:16 xxxxx-01: Removing existing manifest file
    23:13:16 xxxxx-01: Creating a manifest file...
    23:13:16 xxxxx-01: Manifest file created.
    23:13:16 xxxxx-01: Copying .ostype to manifest output directory.
    23:13:18 xxxxx-01: Done in 42 sec(s).
    23:13:21 xxxxx-01: Running post deployment command(s)...
    23:13:21 xxxxx-01: Generating summary of Oryx build
    23:13:21 xxxxx-01: Parsing the build logs
    23:13:22 xxxxx-01: Found 0 issue(s)
    23:13:22 xxxxx-01: Build Summary :
    23:13:22 xxxxx-01: ===============
    23:13:22 xxxxx-01: Errors (0)
    23:13:23 xxxxx-01: Warnings (0)
    23:13:23 xxxxx-01: Triggering recycle (preview mode disabled).
    23:13:24 xxxxx-01: Deployment successful. deployer = Push-Deployer deploymentPath = ZipDeploy. Extract zip. Remote build.
    23:13:54: Deployment to "xxxxx-01" completed.
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71

    5. 通过App Service Web查看App Service的部署信息

    在你的App Service的域名后缀前面加上scm,比如,https://xxxxx-yyyyy-nn.azurewebsites.net/变成
    https://xxxxx-yyyyy-nn.scm.azurewebsites.net/,就能看到你的App Service的部署信息了。

    5.1 查看环境信息

    在这里插入图片描述

    5.2 查看部署log

    甚至还能看到部署的信息
    https://xxxxx-yyyyy-nn.scm.azurewebsites.net/deploymentlogs/

    5.3 查看部署Docker log

    查看Docker log
    https://xxxxx-yyyyy-nn.scm.azurewebsites.net/api/logs/docker/

    5.4 下载并查看部署应用的log

    下载部署在App Service Docker里面的应用的log
    https://xxxxx-yyyyy-nn.scm.azurewebsites.net/api/logs/docker/zip
    下载下来的zip文件就包括应用的log,在第一个log的文件里面
    在这里插入图片描述

    2022-11-20T14:38:52.884307650Z    _____                               
    2022-11-20T14:38:52.884358851Z   /  _  \ __________ _________   ____  
    2022-11-20T14:38:52.884372451Z  /  /_\  \\___   /  |  \_  __ \_/ __ \ 
    2022-11-20T14:38:52.884380951Z /    |    \/    /|  |  /|  | \/\  ___/ 
    2022-11-20T14:38:52.884388151Z \____|__  /_____ \____/ |__|    \___  >
    2022-11-20T14:38:52.884395751Z         \/      \/                  \/ 
    2022-11-20T14:38:52.884402952Z A P P   S E R V I C E   O N   L I N U X
    2022-11-20T14:38:52.884409952Z 
    2022-11-20T14:38:52.884416552Z Documentation: http://aka.ms/webapp-linux
    2022-11-20T14:38:52.884424052Z NodeJS quickstart: https://aka.ms/node-qs
    2022-11-20T14:38:52.884431652Z NodeJS Version : v18.2.0
    2022-11-20T14:38:52.884438852Z Note: Any data outside '/home' is not persisted
    2022-11-20T14:38:52.884446252Z 
    2022-11-20T14:38:55.842142606Z Starting OpenBSD Secure Shell server: sshd.
    2022-11-20T14:38:56.499512442Z Starting periodic command scheduler: cron.
    2022-11-20T14:38:57.796269012Z Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it...
    2022-11-20T14:38:57.806459278Z Build Operation ID: |ZZ0zxKBKLKw=.544f5388_
    2022-11-20T14:38:57.822108134Z Environment Variables for Application Insight's IPA Codeless Configuration exists..
    2022-11-20T14:38:59.415195621Z Writing output script to '/opt/startup/startup.sh'
    2022-11-20T14:38:59.523408785Z Running #!/bin/sh
    2022-11-20T14:38:59.523453286Z 
    2022-11-20T14:38:59.523466686Z # Enter the source directory to make sure the script runs where the user expects
    2022-11-20T14:38:59.523476186Z cd "/home/site/wwwroot"
    2022-11-20T14:38:59.523484787Z 
    2022-11-20T14:38:59.523493287Z export NODE_PATH=/usr/local/lib/node_modules:$NODE_PATH
    2022-11-20T14:38:59.523502387Z if [ -z "$PORT" ]; then
    2022-11-20T14:38:59.523511387Z 		export PORT=8080
    2022-11-20T14:38:59.523521187Z fi
    2022-11-20T14:38:59.523529687Z 
    2022-11-20T14:38:59.523538387Z echo Found tar.gz based node_modules.
    2022-11-20T14:38:59.523546788Z extractionCommand="tar -xzf node_modules.tar.gz -C /node_modules"
    2022-11-20T14:38:59.523555288Z echo "Removing existing modules directory from root..."
    2022-11-20T14:38:59.523563488Z rm -fr /node_modules
    2022-11-20T14:38:59.523571688Z mkdir -p /node_modules
    2022-11-20T14:38:59.523579888Z echo Extracting modules...
    2022-11-20T14:38:59.523587688Z $extractionCommand
    2022-11-20T14:38:59.523595988Z export NODE_PATH="/node_modules":$NODE_PATH
    2022-11-20T14:38:59.523604889Z export PATH=/node_modules/.bin:$PATH
    2022-11-20T14:38:59.523613689Z if [ -d node_modules ]; then
    2022-11-20T14:38:59.523641489Z     mv -f node_modules _del_node_modules || true
    2022-11-20T14:38:59.523651989Z fi
    2022-11-20T14:38:59.523659989Z 
    2022-11-20T14:38:59.523667590Z if [ -d /node_modules ]; then
    2022-11-20T14:38:59.523674990Z     ln -sfn /node_modules ./node_modules 
    2022-11-20T14:38:59.523682290Z fi
    2022-11-20T14:38:59.523688790Z 
    2022-11-20T14:38:59.523695490Z echo "Done."
    2022-11-20T14:38:59.527160046Z PATH="$PATH:/home/site/wwwroot" npm start
    2022-11-20T14:38:59.532954241Z Found tar.gz based node_modules.
    2022-11-20T14:38:59.532985341Z Removing existing modules directory from root...
    2022-11-20T14:38:59.656172850Z Extracting modules...
    2022-11-20T14:39:00.589983271Z Done.
    2022-11-20T14:39:09.119587808Z npm info it worked if it ends with ok
    2022-11-20T14:39:09.121911935Z npm info using npm@6.14.15
    2022-11-20T14:39:09.122844946Z npm info using node@v18.2.0
    2022-11-20T14:39:10.545825075Z npm info lifecycle myexpressapp@0.0.0~prestart: myexpressapp@0.0.0
    2022-11-20T14:39:10.603291258Z npm info lifecycle myexpressapp@0.0.0~start: myexpressapp@0.0.0
    2022-11-20T14:39:10.631101589Z 
    2022-11-20T14:39:10.631206990Z > myexpressapp@0.0.0 start /home/site/wwwroot
    2022-11-20T14:39:10.631221590Z > node ./bin/www
    2022-11-20T14:39:10.631229790Z 
    2022-11-20T14:39:12.799287150Z [0mGET /robots933456.txt [33m404 [0m48.285 ms - 721[0m
    2022-11-20T14:39:13.808576329Z [0mGET / [32m200 [0m40.712 ms - 221[0m
    2022-11-20T14:39:13.818159043Z [0mGET / [32m200 [0m47.632 ms - 221[0m
    2022-11-20T14:39:13.873227196Z [0mGET / [32m200 [0m11.500 ms - 221[0m
    2022-11-20T14:39:14.343606075Z [0mGET /stylesheets/style.css [32m200 [0m52.733 ms - 111[0m
    2022-11-20T14:39:14.692155408Z [0mGET /favicon.ico [33m404 [0m41.995 ms - 721[0m
    
    2022-11-20T14:40:13.792141231Z [0mGET / [32m200 [0m98.869 ms - 221[0m
    2022-11-20T14:40:14.434950924Z [0mGET /stylesheets/style.css [32m200 [0m82.386 ms - 111[0m
    2022-11-20T14:40:14.883193946Z [0mGET /favicon.ico [33m404 [0m138.429 ms - 721[0m
    
    2022-11-20T14:40:37.045537691Z [0mGET / [32m200 [0m132.349 ms - 221[0m
    
    2022-11-20T15:00:06.024510739Z [0mGET / [36m304 [0m847.055 ms - -[0m
    2022-11-20T15:00:06.574238751Z [0mGET /stylesheets/style.css [36m304 [0m219.435 ms - -[0m
    
    2022-11-20T15:11:53.048642190Z    _____                               
    2022-11-20T15:11:53.048694291Z   /  _  \ __________ _________   ____  
    2022-11-20T15:11:53.049666097Z  /  /_\  \\___   /  |  \_  __ \_/ __ \ 
    2022-11-20T15:11:53.049697897Z /    |    \/    /|  |  /|  | \/\  ___/ 
    2022-11-20T15:11:53.049703897Z \____|__  /_____ \____/ |__|    \___  >
    2022-11-20T15:11:53.049708697Z         \/      \/                  \/ 
    2022-11-20T15:11:53.049712897Z A P P   S E R V I C E   O N   L I N U X
    2022-11-20T15:11:53.049716997Z 
    2022-11-20T15:11:53.049720897Z Documentation: http://aka.ms/webapp-linux
    2022-11-20T15:11:53.049724997Z NodeJS quickstart: https://aka.ms/node-qs
    2022-11-20T15:11:53.049728997Z NodeJS Version : v18.2.0
    2022-11-20T15:11:53.049733097Z Note: Any data outside '/home' is not persisted
    2022-11-20T15:11:53.049737197Z 
    2022-11-20T15:11:55.021691922Z Starting OpenBSD Secure Shell server: sshd.
    2022-11-20T15:11:55.438951249Z Starting periodic command scheduler: cron.
    2022-11-20T15:11:56.363568272Z Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it...
    2022-11-20T15:11:56.377064257Z Build Operation ID: |8r8eAPAzaWg=.92bae762_
    2022-11-20T15:11:56.391387347Z Environment Variables for Application Insight's IPA Codeless Configuration exists..
    2022-11-20T15:11:57.581600238Z Writing output script to '/opt/startup/startup.sh'
    2022-11-20T15:11:57.669418691Z Running #!/bin/sh
    2022-11-20T15:11:57.669491891Z 
    2022-11-20T15:11:57.669503592Z # Enter the source directory to make sure the script runs where the user expects
    2022-11-20T15:11:57.669529492Z cd "/home/site/wwwroot"
    2022-11-20T15:11:57.669537892Z 
    2022-11-20T15:11:57.669545192Z export NODE_PATH=/usr/local/lib/node_modules:$NODE_PATH
    2022-11-20T15:11:57.669710193Z if [ -z "$PORT" ]; then
    2022-11-20T15:11:57.669973194Z 		export PORT=8080
    2022-11-20T15:11:57.669991095Z fi
    2022-11-20T15:11:57.670000895Z 
    2022-11-20T15:11:57.670009595Z echo Found tar.gz based node_modules.
    2022-11-20T15:11:57.670018395Z extractionCommand="tar -xzf node_modules.tar.gz -C /node_modules"
    2022-11-20T15:11:57.670027195Z echo "Removing existing modules directory from root..."
    2022-11-20T15:11:57.670035995Z rm -fr /node_modules
    2022-11-20T15:11:57.670043895Z mkdir -p /node_modules
    2022-11-20T15:11:57.670051595Z echo Extracting modules...
    2022-11-20T15:11:57.670059795Z $extractionCommand
    2022-11-20T15:11:57.670067695Z export NODE_PATH="/node_modules":$NODE_PATH
    2022-11-20T15:11:57.670080295Z export PATH=/node_modules/.bin:$PATH
    2022-11-20T15:11:57.670088895Z if [ -d node_modules ]; then
    2022-11-20T15:11:57.670114495Z     mv -f node_modules _del_node_modules || true
    2022-11-20T15:11:57.670140396Z fi
    2022-11-20T15:11:57.670164696Z 
    2022-11-20T15:11:57.674019820Z if [ -d /node_modules ]; then
    2022-11-20T15:11:57.674038920Z     ln -sfn /node_modules ./node_modules 
    2022-11-20T15:11:57.674047320Z fi
    2022-11-20T15:11:57.674054320Z 
    2022-11-20T15:11:57.674061220Z echo "Done."
    2022-11-20T15:11:57.674073620Z PATH="$PATH:/home/site/wwwroot" npm start
    2022-11-20T15:11:57.674327822Z Found tar.gz based node_modules.
    2022-11-20T15:11:57.674622524Z Removing existing modules directory from root...
    2022-11-20T15:11:57.796659092Z Extracting modules...
    2022-11-20T15:11:58.284379911Z Done.
    2022-11-20T15:12:08.957112831Z npm info it worked if it ends with ok
    2022-11-20T15:12:08.958695651Z npm info using npm@6.14.15
    2022-11-20T15:12:08.960154270Z npm info using node@v18.2.0
    2022-11-20T15:12:11.535790412Z npm info lifecycle myexpressapp@0.0.0~prestart: myexpressapp@0.0.0
    2022-11-20T15:12:11.544406123Z npm info lifecycle myexpressapp@0.0.0~start: myexpressapp@0.0.0
    2022-11-20T15:12:11.570229355Z 
    2022-11-20T15:12:11.570281956Z > myexpressapp@0.0.0 start /home/site/wwwroot
    2022-11-20T15:12:11.570297056Z > node ./bin/www
    2022-11-20T15:12:11.571325169Z 
    2022-11-20T15:12:15.106281344Z ***********************************************
    2022-11-20T15:12:15.106703543Z Start the applicaiton
    2022-11-20T15:12:15.106742943Z ***********************************************
    2022-11-20T15:12:15.264033765Z [0mGET /robots933456.txt [33m404 [0m66.465 ms - 721[0m
    
    2022-11-20T15:13:57.063080724Z ***********************************************
    2022-11-20T15:13:57.063194727Z Enter the example demo
    2022-11-20T15:13:57.063213427Z ***********************************************
    2022-11-20T15:13:57.193713828Z [0mGET / [32m200 [0m1778.700 ms - 227[0m
    
    2022-11-20T15:13:41.519706220Z    _____                               
    2022-11-20T15:13:41.519775121Z   /  _  \ __________ _________   ____  
    2022-11-20T15:13:41.519789121Z  /  /_\  \\___   /  |  \_  __ \_/ __ \ 
    2022-11-20T15:13:41.519795821Z /    |    \/    /|  |  /|  | \/\  ___/ 
    2022-11-20T15:13:41.519802821Z \____|__  /_____ \____/ |__|    \___  >
    2022-11-20T15:13:41.519809521Z         \/      \/                  \/ 
    2022-11-20T15:13:41.519815921Z A P P   S E R V I C E   O N   L I N U X
    2022-11-20T15:13:41.519822121Z 
    2022-11-20T15:13:41.519828421Z Documentation: http://aka.ms/webapp-linux
    2022-11-20T15:13:41.519851022Z NodeJS quickstart: https://aka.ms/node-qs
    2022-11-20T15:13:41.519857522Z NodeJS Version : v18.2.0
    2022-11-20T15:13:41.519863222Z Note: Any data outside '/home' is not persisted
    2022-11-20T15:13:41.519868922Z 
    2022-11-20T15:13:43.216105874Z Starting OpenBSD Secure Shell server: sshd.
    2022-11-20T15:13:43.827622004Z Starting periodic command scheduler: cron.
    2022-11-20T15:13:44.991757440Z Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it...
    2022-11-20T15:13:45.019955433Z Build Operation ID: |GEQyjIHtYOs=.77ba5015_
    2022-11-20T15:13:45.034686238Z Environment Variables for Application Insight's IPA Codeless Configuration exists..
    2022-11-20T15:13:48.756384008Z Writing output script to '/opt/startup/startup.sh'
    2022-11-20T15:13:48.838144547Z Running #!/bin/sh
    2022-11-20T15:13:48.838230948Z 
    2022-11-20T15:13:48.838240748Z # Enter the source directory to make sure the script runs where the user expects
    2022-11-20T15:13:48.838247748Z cd "/home/site/wwwroot"
    2022-11-20T15:13:48.838254448Z 
    2022-11-20T15:13:48.838260748Z export NODE_PATH=/usr/local/lib/node_modules:$NODE_PATH
    2022-11-20T15:13:48.838267648Z if [ -z "$PORT" ]; then
    2022-11-20T15:13:48.838273948Z 		export PORT=8080
    2022-11-20T15:13:48.838280549Z fi
    2022-11-20T15:13:48.838286849Z 
    2022-11-20T15:13:48.838605553Z echo Found tar.gz based node_modules.
    2022-11-20T15:13:48.838621353Z extractionCommand="tar -xzf node_modules.tar.gz -C /node_modules"
    2022-11-20T15:13:48.838629553Z echo "Removing existing modules directory from root..."
    2022-11-20T15:13:48.838636853Z rm -fr /node_modules
    2022-11-20T15:13:48.838643954Z mkdir -p /node_modules
    2022-11-20T15:13:48.838650754Z echo Extracting modules...
    2022-11-20T15:13:48.838657954Z $extractionCommand
    2022-11-20T15:13:48.838664554Z export NODE_PATH="/node_modules":$NODE_PATH
    2022-11-20T15:13:48.838671954Z export PATH=/node_modules/.bin:$PATH
    2022-11-20T15:13:48.838678554Z if [ -d node_modules ]; then
    2022-11-20T15:13:48.838700454Z     mv -f node_modules _del_node_modules || true
    2022-11-20T15:13:48.838708554Z fi
    2022-11-20T15:13:48.838714855Z 
    2022-11-20T15:13:48.838721055Z if [ -d /node_modules ]; then
    2022-11-20T15:13:48.838727355Z     ln -sfn /node_modules ./node_modules 
    2022-11-20T15:13:48.838732855Z fi
    2022-11-20T15:13:48.838738755Z 
    2022-11-20T15:13:48.838926358Z echo "Done."
    2022-11-20T15:13:48.850006212Z PATH="$PATH:/home/site/wwwroot" npm start
    2022-11-20T15:13:48.850091813Z Found tar.gz based node_modules.
    2022-11-20T15:13:48.850109813Z Removing existing modules directory from root...
    2022-11-20T15:13:49.266260410Z Extracting modules...
    2022-11-20T15:13:49.829250051Z Done.
    2022-11-20T15:14:05.546196172Z npm info it worked if it ends with ok
    2022-11-20T15:14:05.546273773Z npm info using npm@6.14.15
    2022-11-20T15:14:05.546292573Z npm info using node@v18.2.0
    2022-11-20T15:14:08.417482264Z npm info lifecycle myexpressapp@0.0.0~prestart: myexpressapp@0.0.0
    2022-11-20T15:14:08.448430583Z npm info lifecycle myexpressapp@0.0.0~start: myexpressapp@0.0.0
    2022-11-20T15:14:08.482221213Z 
    2022-11-20T15:14:08.482282213Z > myexpressapp@0.0.0 start /home/site/wwwroot
    2022-11-20T15:14:08.482297613Z > node ./bin/www
    2022-11-20T15:14:08.482306713Z 
    2022-11-20T15:14:10.622264949Z ***********************************************
    2022-11-20T15:14:10.623912056Z Start the applicaiton
    2022-11-20T15:14:10.624365057Z ***********************************************
    2022-11-20T15:14:10.744351819Z [0mGET /robots933456.txt [33m404 [0m60.877 ms - 721[0m
    
    2022-11-20T15:14:40.852039998Z ***********************************************
    2022-11-20T15:14:40.852488286Z Enter the example demo
    2022-11-20T15:14:40.852548584Z ***********************************************
    2022-11-20T15:14:40.868456271Z [0mGET / [32m200 [0m42.645 ms - 227[0m
    
    2022-11-20T15:14:47.356308198Z ***********************************************
    2022-11-20T15:14:47.356820695Z Enter the example demo
    2022-11-20T15:14:47.357968287Z ***********************************************
    2022-11-20T15:14:47.379758830Z [0mGET / [32m200 [0m30.954 ms - 227[0m
    
    2022-11-20T15:14:53.750836482Z ***********************************************
    2022-11-20T15:14:53.750892082Z Enter the example demo
    2022-11-20T15:14:53.750908682Z ***********************************************
    2022-11-20T15:14:53.767062366Z [0mGET / [32m200 [0m34.209 ms - 227[0m
    
    2022-11-20T15:16:56.781710282Z ***********************************************
    2022-11-20T15:16:56.782437098Z Enter the example demo
    2022-11-20T15:16:56.782457799Z ***********************************************
    2022-11-20T15:16:56.814575134Z [0mGET / [32m200 [0m77.894 ms - 227[0m
    2022-11-20T15:16:57.268719623Z [0mGET /stylesheets/style.css [36m304 [0m59.285 ms - -[0m
    
    2022-11-20T15:17:06.703932640Z ***********************************************
    2022-11-20T15:17:06.704031732Z Start the applicaiton
    2022-11-20T15:17:06.730009610Z ***********************************************
    2022-11-20T15:17:06.940698114Z [0mGET /user1 [33m404 [0m259.611 ms - 721[0m
    2022-11-20T15:17:10.251955118Z ***********************************************
    2022-11-20T15:17:10.252035719Z Start the applicaiton
    2022-11-20T15:17:10.252053219Z ***********************************************
    2022-11-20T15:17:10.269605536Z [0mGET /user [33m404 [0m30.908 ms - 721[0m
    
    2022-11-20T15:17:14.608191430Z ***********************************************
    2022-11-20T15:17:14.609749640Z Enter the example demo
    2022-11-20T15:17:14.610023342Z ***********************************************
    2022-11-20T15:17:14.625827347Z [0mGET / [36m304 [0m31.973 ms - -[0m
    2022-11-20T15:17:14.976112471Z [0mGET /stylesheets/style.css [36m304 [0m6.874 ms - -[0m
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243
    • 244
    • 245
    • 246
    • 247
    • 248
    • 249

    5.5 下载并查看部署应用的环境变量

    https://xxxxx-yyyyy-nn.scm.azurewebsites.net/env
    在这里插入图片描述

    5.6 下载并查看部署应用服务器的目录

    https://xxxxx-yyyyy-nn.azurewebsites.net/webssh/host
    在这里插入图片描述
    在这里插入图片描述

    6. 通过Azure Portal查看应用的Log

    6.1 “Log Stream” 查看应用的Log

    登录Azure 的portal,找到想要的App Service 并点击“Log Stream” 查看应用的Log
    在这里插入图片描述

    6.2 “Diagnostic settings ” 查看应用的Log

    此外还能通过Diagnostic settings 把App Service的应用Log注入到Log Analysis workspace
    在这里插入图片描述
    回到Log Analytics workspace,输入下面的命令,就能看到部署在App Service里面的Log了。

    AppServiceConsoleLogs
    
    • 1

    在这里插入图片描述

  • 相关阅读:
    Linux驱动BSP (pinctrl&gpio子系统)
    Ubuntu22.04安装及初始配置
    超市积分管理系统(Java+Web+MySQL)
    C语言牛客网(NowCoder)刷题篇
    TensorRT来加速YOLO v5推理与检测
    认识异常-java
    ESP8266/esp32接入阿里云物联网平台点灯控制类案例
    将组件发布到Maven中央仓库
    Asp.net Core系列学习(1)
    vue 搜索后让搜索的关键字高亮
  • 原文地址:https://blog.csdn.net/chancein007/article/details/127955820