Showing posts with label debugging. Show all posts
Showing posts with label debugging. Show all posts

Friday 12 February 2021

APIM debugging, tracing, monitoring tricks and tips

Debugging APIM requests from Visual Studio code 

Has an extension for debugging APIM.

Azure API Management - Visual Studio Marketplace


It's also useful to have a APIM requesting/client extension installed

Tracing APIM

To get a full trace add the HTTP header "Ocp-Apim-Trace: true" to the request and the response shall contain a URL to retrieve the trace information.




App Insights for APIM
Logs in three places:
  1. Incoming requests (come into APIM)
  2. Dependency request (go to backend/outgoing)
  3. if an exception occurs it is also logged in App Insights
So logging can be set at either the global or API level.
Setup in APIM > Monitoring > Application Insights (link APIM to the App insights Logger).

Documentation Tips

Ensure you fill in relevant descriptions and summaries.  It's also key to provide examples.  

https://swagger.io/docs/specification/adding-examples/

My Technical Working Notes for Microsoft Technology: APIM OpenAPI Specification Documentation Example within the Developer Portal (pbeck.co.uk)

APIM documentation updates on the Developer portal (after re-publishing).  It has a great UI, but ensure the summaries are added for param/attributes to get a truly rich integration set of documentation (it will save so many questions and time).   I also like to add a getting started guide, keep it short and simple and most importantly have a simple explanation of security/authentication and connectivity.

- in: query
  name: age
    schema:
      type: integer
      maximum: 3
    examples:       # Multiple examples
      max: # Distinct name
        value: 3   # Example value
        summary: The age is dependent on dob, min is 0, can't be negative 

Wednesday 13 January 2016

Debug SharePoint ClientContext using IE Developer tools

Overview:  I have a redirect that looks at my client context and performs a redirect.  Fiddler is a good option for viewing JS and debugging but as IE developer tools is not my normal tool for JS debugging, I thought I'd try use it to debug my issue.  I need to debugging a JavaScript redirect (302) using IE Developer Tools and breakpoints.

Steps:
1. Fn + F12 to get the IE Developer Tools
2. Enter the redirection url https://demo.dev/sites/demo/SitePages/Redirection.aspx in IE
3. As the page is running hit the "Esc" key to stop the browser (I need it to get the js files in the redirection page).

4. The Folder Icon mark as point 1 in red on the diagram is used to find the js file to debug.
5. Open the js file step 2 and step 3 in the red annotation above.
6. Set break point as shown below
7. A watch windows is provided. Variables are easy to follow.
8. When you refresh if the breakpoints are set, you will get stopped at the break points you previously setup in the steps above for subsequent runs.


Wednesday 26 February 2014

Remote Debugging SharePoint 2013

Overview:  Object reference not set to an instance of an object is all the information I have in my customers ULS logs.  I need to debug an application in production that does not contain Visual Studio 2012.

My Steps:
  • Ran the Remote Debugguer (msvsmon.exe) on 1 of the production servers
  • Added a host file to point to my production server "SP-WFE1" (optional depending on where the web requests originate from)
  • Opened Visual Studio 2012 on a VM containing the projected (hooked up to TFS 2012) and opened the solution (.sln).
  • Select Tools > Attach to Process

..... Finish when time permits


More Info:
http://msdn.microsoft.com/en-us/library/ff649389.aspx
http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/03/05/how-to-remote-debugging-a-web-application.aspx
 

Tuesday 9 November 2010

Could not load the Web.config configuration file when debugging in SharePoint

Problem: I can't debug my SharePoint projects using Visual Studio 2010 (VS).  I get the error "Could not load the Web.config configuration file.  Check the file for any malformed XML elements, and try again.  The following error occurred: Cannot connect to the SharePoint site.  If you moved this project to a new computer or if the Url of the SharePoint site has chnaged since you created the project, update the Site Url property of the project." in VS when I try debug.



Initial Hypothesis: I recenctly renamed all my VS projects in my VS solution.  The error tells me to check the "Site Url" on each of my projects.  I missed the project that was set as my start up project.

Resolution: Set the "Site Url" property in VS on the projects.

Thursday 29 July 2010

Custom error and call stack info is not showing on my SP dev machine

Problem: I have turned my web.config file customErrors mode to "Off" however the error is telling me to turn it off or RemoteOnly. Therefore my screen is not showing me the problem. You can debug but the feedback is not provided on the erring SP page.
Hypothesis: Changing the web.config in the IIS SharePoint 2010 web site does not take effect. Ensure the web.config is correct and ensure other related web.configs used by the site are updated.
Resolution: Update the following 3 web.configs:

  • 14\CONFIG
  • 14\TEMPALTE\LAYOUTS
  • Current IIS web.config
web.configs should read:
customErrors mode="Off" />
SafeMode MaxControls="200" CallStack="true" ... AllowPage LevelTrace="true">
compilation batch="false" debug="true" >
More Info:

http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010general/thread/2673ae4e-0b26-42ba-a158-1ceb63985721
http://blogs.msdn.com/b/amitsh/archive/2007/11/01/why-i-am-not-able-turn-off-customerrors.aspx