Azure function debug and deployment separately

521 views Asked by At

I am having an Azure function VS project with multiple functions in it.

  1. Can I debug 1 function on its own without starting other functions in the same project? When I debug the project on visual studio all functions started and run.

  2. Can I update just 1 function instead of all functions in 1 function app project? When publish from Visual Studio, the whole function app is pushed.

  3. Most importantly how do I maintain the Enabled/Disabled status of functions on Azure portal after deployment. What happens now is all functions turn to be Enabled after each deployment and I have to manually turn those off.

2

There are 2 answers

2
Wah Yuen On
  1. Yes you can. You can utilize a setting in the host.json file to specify the functions that you wish to have loaded during debug.

// Array of functions to load. Only functions in this list will be enabled. // If not specified, all functions are enabled. functions": [ "QueueProcessor", "GitHubWebHook" ]

Where QueueProcessor and GitHubWebHook is the 'name' of your function itself

[FunctionName("QueueProcessor")]

For other host.json settings see here

  1. You 'could' choose to split out your functions into separate projects with the publish profile pointing to the same Function 'application' if you really want to ensure that only that specific code is being published. Personally, I have generally just pushed the whole project with multiple functions up each time I make a change.

  2. I have found that the settings that I specify from step 1, if published, will propagate out to the Functions portal

1
Garth Mason On

There is also a DisabledAttribute in Microsoft.Azure.WebJobs you can used to mark function as disabled.

The attribute constructor provides overloads to link to an application setting in your function app so you can disable the function conditionally.

Note: there were earlier issues with this attribute but they have been resolved now.