Search code examples
c#visual-studio-codeazure-functionsvscode-tasksazure-functions-core-tools

Is there a way to watch for file changes while developing azure functions?


For dotnet there is dotnet watch run For node there is nodemon

Is there anyway to watch for file changes while developing azure functions? So far, I have to func start after every change in order to test it out. I haven't seen any information related to this.


Solution

  • I found a workaround solution here:

    https://github.com/Azure/azure-functions-core-tools/issues/1239#issuecomment-669018902

    Add this to your csproj:

      <Target Name="RunFunctions">
        <Exec Command="func start" />
      </Target>
    

    Then you can run with watch by calling this:

    dotnet watch msbuild /t:RunFunctions
    

    NB: If you want to use some common commands, you could configure a package.json with a start script e.g.

    {
      "scripts": {
        "start": "dotnet watch msbuild /t:RunFunctions"
      }
    }
    

    Then you can simply run with yarn start