我如何观察天蓝色功能的变化? [英] How can i watch for changes in my azure functions?

查看:50
本文介绍了我如何观察天蓝色功能的变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用用NODE JS编写的Azure函数.我正在使用

I am using azure functions written in NODE JS. I am starting the local server with

func host start

,一切正常.但是问题是当我在azure函数中进行了一些更改时-例如,当我添加一个简单的控制台日志时,就使用了index.js文件

and everything works fine. But the problem is when i change something in my azure functions - index.js file for example when i add one simple console log


module.exports = async function (context, req) {
        console.log('request came');
        context.res = {
            body: { success: true, message: null, response: context.bindings.inputDocument }
        };
};

服务器未重新启动,我需要再次停止服务器运行func host start来查看更改是否不好.在nodejs中,我们有nodemon,在azure函数中是否有此功能,我可以使用它们监视更改而无需停止运行并在每次更改时启动服务器?

the server is not restarted, and i need to stop the server run again func host start to see the changes which is not good. In nodejs we have nodemon, is there something to this in azure functions with which i can watch for changes without stoppint and starting the server on every change ?

我尝试过的事情

我尝试添加host.json文件

I tried adding in my host.json file

  "watchDirectories": [ "*" ] 

但没有成功.

我也尝试过

在package.json文件的脚本中编辑start属性

editing the start property in the scripts in package.json file

"scripts": {
    "start": "start npm run watch & npm run start:host",
    "test": "echo \"No tests yet...\""
  },

代替

"scripts": {
    "start": "func start",
    "test": "echo \"No tests yet...\""
  },

但仍然没有成功.

我正在使用azure函数v2.

I am using azure functions v2.

推荐答案

您可以启动两个进程(基于@ azure/functions 1.2.3):

You can start two processes (based on @azure/functions 1.2.3):

  • 过程1: tsc -w (或 npm run watch )
  • 过程2: func start (或 npm start )
  • Process 1: tsc -w (or npm run watch)
  • Process 2: func start (or npm start)

然后,Typescript编译器将在监视模式下工作,自动编译更改,并且azure func工具还将在更改时重新加载其功能.

The Typescript compiler will then work in watch mode, compile changes automatically, and the azure func tool will also reload it's functions on changes.

这篇关于我如何观察天蓝色功能的变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆