Webhook Success Key #5: Know How to Debug Your Webhooks

John E. Huschka, January 25, 2018

Target Audience:
SharePoint Developer
Technology:

Azure Functions — Internet cloud based custom code for SharePoint and Office 365.

SharePoint Webhooks — Connections that allow us to attach custom code to SharePoint that is called when events occur.

This post is part of our blog series and demonstration code on achieving webhook success.

If you implement your Azure-based webhook as a compiled .NET solution, it is tricky to debug it within Visual Studio. Here are the steps, illustrated using Visual Studio 2017.

The first step is to make sure that you have deployed a build of your code in debug configuration. If you are publishing from Visual Studio, you can select the “Debug” configuration when you publish:

Visual Studio Debug Configuration

If you have a debug-able build deployed to Azure, you should see the debug symbol file(s) available in Azure. You can see this within Visual Studio’s Cloud Explorer:

Azure Function Debug Symbol Files

In addition, you must enable debugging for the Azure App Service within Azure. You can do this from the Azure portal, within the “Application Settings” for the App Service:

Azure Function Enable Debugging

Note: If you are using Azure Government, as of this writing, no managment user interface is provided for App Services. You must manage it through other tools/techniques, such as this REST Update Configuration API.

To debug the function, Visual Studio will need to connect to the Azure App Service. To do this, you will need the credentials for the App Service. An effective way to do this is to use the App Service Portal's “Download publish profile” button:

Azure Download Publish Profile

When you click on the button, you will download a file that contains the required credentials:

Azure Publish Profile Credentials

Finally, you start debugging in Visual Studio from the Debug/Attach to Process menu. Enter the App Service’s URL (no protocol prefix), followed by ":4022" into the Connection Target field and press the Enter key. You will be prompted for the App Service credentials.

Key (or copy/paste) the user name from the publish profile, prefixed with a period and a backslash (“.\”) and then key the password. Your window will appear like this:

Visual Studio Debug Credentials

Note: We rarely "Remember credentials" because it is easy to mis-enter them and end up with them remembered incorrectly.

Once you have connected to the App Service endpoint, you will see the the list of processes available to you for debugging. You should be able to attach to the worker process (w3wp.exe):

Visual Studio Debug Credentials

Now, as long as you remain attached, you will be able to debug in Visual Studio as normal the next time SharePoint triggers the webhook:

Visual Studio Debug Credentials

Visual Studio provides you with powerful debugging capabilities, even to the Azure cloud. Proper use can give you tremendous visibility into your webhook, allowing you to quickly solve problems.


 


We at Collaboration Foundry are experts in SharePoint and Office 365. If you need assistance, we can help. Contact us.
Also, don't forget to take a look at our blog for more helpful tips and techniques.


Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
CAPTCHAThis question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
10 + 8 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.