简体   繁体   中英

Debugging Azure functions in Visual Studio

I am developing a logic app and hosting there several custom functions. These are csx files, so it is C# code (script code).

For now I use only the Azure web frontend to edit the function and testing it. But I think that this is not the best way, because I want have a continuous deployment. So I want to use a git repo to store there my code. That the deployment process take to publish the changes.

So is it possible to debug my function locally? Maybe with an emulator or s.th.?

I tried this link to setup a local environment: https://azure.microsoft.com/da-dk/documentation/articles/functions-run-local/#to-run-locally

But I do not know if this is the right way to debugg the functions locally.

by the way, is it possible to run a logic app locally too?

Check this doc out

It's what I use to develop locally. Basically after installing the tools you just hit F5 (or Debug) and Visual Studio compiles your functions and sets up a localhost connection for them. You can then use a free program like Postman (my personal favorite) to trigger the functions. If you have a breakpoint set, it will then be hit after calling the function. Once it starts up, you'll eventually see something like this after everything is done:

在此输入图像描述

Note that it's using http and not https. You can then use Postman or whatever to access the function via the URL listed. Also note that when running locally, it doesn't seem to care if you have your function set to require an admin/function key, nor will it care if it requires authentication.

With this set up, I test all my code locally, then when it's done I submit it to source control and then, using the plugin obtained from the link, I publish my functions to Azure. In my case, I'm using TFS and not Git so I can't (currently as of this writing) hook it up to Azure's continuous integration. Since you're using Git, you won't have to deal with the publish step.

I would say that it depends. For example, if you'll use blob triggers, you won't be able to test locally, just "mock" that.

Here's a useful link from the offical doc:

https://azure.microsoft.com/en-us/documentation/articles/functions-run-local/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM