How to debug Azure Functions on Azure Portal? - azure

I have created an Azure function. Can i debug Azure Functions on Azure portal without visual studio?
I am passing a complex parameter as File Model, i have to see what's coming in parameter value in debug mode?

There is no debug experience in the portal. Constrained to just the portal, you'll have to use log output to debug.
You might also look into the Azure Functions CLI which provides a local debugging experience. it doesn't require VS.

For Azure Functions V1, you can attach debugger then debug from Visual Studio as the code runs inside csx script:
https://markheath.net/post/remote-debugging-azure-functions
For Azure Functions V2, It seems there is no way till now but you can get massive logs and analytics based on your need.
Or may be you can find a way by uploading the debug version contains (.pdb files) and try to attach debugger. Check this:
https://github.com/Azure/Azure-Functions/issues/872
And i opened an issue here to ask about this:
https://github.com/Azure/Azure-Functions/issues/1051
I have another easiest solution It may feet in your issue or may not, I faced a situation that i want to test azure function webhook but that wouldn't work with localhost so the only solution for me is to test it after publishing and for that i was in need for debug on azure itself but there is another brilliant solution:
You can expose your localhost urls to the public by using many services and for example:
https://localtunnel.github.io/www/
Make sure that you installed nodejs, and follow the instructions to install the localtunel package globally through npm and then you can generate a public url for your localhost webhook so you can verify it against any third party and debug it.

Through Azure Functions Portal you won't able to have debugging tools for do that.
But you can you some ways to debug your azure functions:
1º) Remote debugging using Visual Studio IDE;
2º) Local Debugging using both Visual Studio or VS Code, too;
3º) Event though you're using Azure Functions CLI, you'll need some IDE, that is Visual Studio or VS Code;
The only way that there is on Azure Functions Portal to have something like a debugging is the LOG Window that is localized right below Function Code Window.

Related

Is there an alternative way to add another Registered Cloud to Visual Studio?

I've lost the ability to log in to Visual Studio using my work account which is prohibiting me from being able to connect to my Azure Dev Ops repos. I believe the reason is because it's trying to auth me against Azure Gov instead of Azure Comm where my account lives.
When I go to my account options I see the US Azure Gov cloud as registered and when I click "Add" I can see the other Gov clouds; but I don't see the commercial cloud. And when I try to add https://login.microsoftonline.com/ manually, it complains that the server returned a 404. Doing a trace reveals the GET to the metadata endpoint is the culprit. https://login.microsoftonline.com/metadata/endpoints?api-version=1.0
I've checked with other developers and they do have it in their list along with the others I have; they have no issues logging in or connecting to the repos. We're running the same major version of VS 2019 - 16.8.x.
Is there an alternative way to register the comm cloud or get that list to be populated with it?
UPDATE: updated to 16.9.4 without luck.
My google-fu finally kicked in and I found a solution.
Near the bottom of the answer from TianyuSun-MSFT, they suggest:
...you can also close all Visual Studio instances and go to C:\Users[user name]\AppData\Local.IdentityService then rename(or delete) the .IdentityService folder, after that you can restart Visual Studio 2019 and try to log in again.
That worked. But before I did it, I investigated the json configs in there and saw a lot pertaining to older versions I no longer have installed. Perhaps, that was the issue.
Once I restarted and logged in, the commercial cloud was automatically added to the list of Registered Clouds.

How can I debug on Azure Devops VSO

I have made a task for Azure Devops Server pipeline.
On the local Azure Dev-Ops server, I can upload extensions from the local machine wrapped in VSIX file and examine the agent on the machine itself. The agent has the deployed DLL's from the extension and I always change specific DLL that has Logger inside and it prints to console on the pipeline itself.
How can I check if my task is compatible with the cloud version?
And off course if it is, how can I debug it?
The only possible way I found to insert my task in VSO is through the Microsoft DevOps marketplace, but I cannot upload the whole extension once per each change in code.
Also, didn't find a way to upload personal tasks to the marketplace. The private version is not helping because I can see it from within the server just like my clients.
Any advice or debug experience on that platform is appreciated.
Please follow this devblogs, it described how you can work and debug extension directly inside your IDE without publishing it to the marketplace.
Since this blog is very detailed, just mention the key steps.
Based on debugging purposes, you need create a special manifest, for sample I specify it as vss-extension-debug.json:
{
...
"id": "dev-extension",
"name": "Dev-Extension",
"baseUri": "https://localhost:44362",
...
}
You can customized the id and name by yourself. The most important and magic is baseUri, this will tell the VSTS server to load the extension from localhost where we can run and debug it in IISExpress from Visual Studio.
Note: Since our server need extension served from a secure source, please ensure enable SSL mode to run IISExpress

How to debug Azure Functions using Visual Code

I have an existing set of functions in an Azure Functions App written in C# Script. I've downloaded the zip file from the Azure portal and opened the directory in Visual Code. I can also log on to the Azure account from Visual Code and can see the functions. If I right-click, I get options to start and stop streaming logs
However, I don't know how to configure my environment so that I can edit and debug these functions locally. I've found instructions for creating a new Function App, but haven't found ones that describe how to work with an existing app.
As mentioned in this post, for now we can't debug(add break points to) C# script(.csx) functions in VS Code.
We can only run csx function both on Azure and locally. Open the function app folder in VS code, follow steps below.
Check function runtime version(~1 or ~2) and follow tutorial to install Azure Function core tools.
If we use ~2 runtime, you need to register binding extensions for all triggers/in/output except Http and Timer triggers.
If we want to use settings(like AzureWebJobsStorage) in Application settings, copy them into local.settings.json. Or we can right click on Application settings of the Function app in VS Code, click Download Remote Settings(In this way, some invalid settings for local env are downloaded as well).
Input Ctrl+` to open terminal and input func host start in terminal to run functions.
For local dev, I do recommend you to use C# pre-compiled code instead of C# script, which is much easier to work with. To do this transformation, follow this tutorial, new a c# function app locally, copy your code in .cs files. We basically don't need to modify the logic code except adding some package and namespace references.

Where can i find the code of an Azure Function?

I'm new to Azure Functions and been thrown into a project without a proper introduction and anybody I could ask is out of office. My simple most likely stupid question is; where can I find the actual code?
In the azure portal, the functions are listed as "read-only" and only contains a function.json. The resource is an App Service and it has a couple of functions. There is no link to any git repository in properties.
Read-only Functions would be compiled and published (e.g. through Visual Studio or a CI/CD pipeline.) The Azure Functions Portal engineers are working on a new, improved experience for this but for now, if your Function app has a deployment source configured, you can view it from the Portal in two ways from your Function app:
Platform Features > Deployment Options.
Platform Features > Resource Explorer. In the file tree on the lefthand side, find your Function app's name, and under that, sourcecontrols. Click to expand in the righthand window.
If your Function app doesn't have a deployment source configured (e.g. your team has been publishing code manually) then things get harder. Depending on how your company has set up their source control and what you already have access to, the function.json you see might help: the entryPoint property in a build-generated function.json will give you the full assembly name of that function (e.g. VSSample.HelloSequence.Run). That or the assembly name of the uploaded DLL in the scriptfile property might help you locate the project.
Good luck! Keep posting if you have further questions; we're here to help.
AFAIK, if we create the azure function in the Visual Studio and publish it to Azure(there may be other ways), it will appear in the situation you described like the screenshot.
Actually, the code is existing in the portal, but the code has been compiled, you could access it in the Platform features -> Advanced tools (Kudu) -> Debug console.
If you want to get the .cs file, I think you should ask it for your coworkers, there will not be in azure.
You said that the Azure function is listed as "read-only". Did you check from the Application Settings menu if you can change the Azure function app edit mode to Read/Write?

Remote Debugging Azure Mobile Service

Trying to debug azure mobile service running in the cloud. I have published debug configuration, in the options indicated to allow debugging non JustMyCode and use source server.
Attach to running process works and I could put break points and step through the code, though I could not get the values of any variables. Even 'this' would not show the values in the watch window.
Prior to that I was trying to debug a release published configuration and the watch used to display values of some of the variables. Others were indicated that due to optimizations values are not available.
Thanks for help,
Ruben
I think you did something wrong, because if you did the remote debug the break point should be hit and you can see all data.
Please see this article
Cconnecting a menu app to azure mobile service > How to do the remote debugging
If it not help, provide a movie with that you are doing :)
I recommend to have Azure SDK 2.5 and Visual Studio 2013 update 4

Resources