4

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?

OmG
  • 18,337
  • 10
  • 57
  • 90
Sascha
  • 601
  • 1
  • 8
  • 23

2 Answers2

4

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:

enter image description here

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.

Architekt
  • 2,141
  • 1
  • 22
  • 27
  • does this work with c#? Because in the doc there is described the node js way. And a breakpoint in c# will not bit hit on my machine :( – Sascha Feb 28 '17 at 06:31
  • The doc that I linked is for C#. And yes it works in C#, that's what I use locally. I can hit breakpoints and view variables. If you aren't hitting breakpoints make sure you have installed everything. At the top of that doc make sure you read the bold part about the update on 12-6-2016. Also make sure you're calling your localhost and using http (as you can see in my screenshot above). – Architekt Feb 28 '17 at 16:45
1

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/

Thiago Custodio
  • 17,332
  • 6
  • 45
  • 90
  • So I have an table storage trigger. It seems that there will be no support for that at the moment and I must mock that too? – Sascha Sep 02 '16 at 05:05
  • Since the functions are based on cloud events, I would say that not all of them, you'll be able to test locally, and you should mock them. My suggestion for you is to create a separate subscription only for test, and them, you can test all of your functions with real events on the cloud. – Thiago Custodio Sep 04 '16 at 20:58
  • Queue triggers work. I'm not sure about blobs and tables but if queue triggers work I would think the others would too. I just tried this yesterday. It was however using my queue storage in the cloud, not a local copy of the queue. – Architekt Feb 28 '17 at 16:46
  • 1
    Check the connection string in your functions.json. Probably it's pointing to your Azure Queue. Try to replace it to UseDevelopmentStorage=true – Thiago Custodio Feb 28 '17 at 20:36