IIS hosted faulted workflow services - iis

I'm hosting my workflow services in IIS and I need to perform some custom actions when an instance is faulted for an internal exception during its excecution.
I found the WorkflowUnhandledExceptionBehavior extension, but there I can only use predefined actions. I would like to be able to have some "event" I can subscribe to to be able to run my own logic.
I think I should use a custom behavior, but where could I found a good example?
Thanks

It depends a bit on what you want/need to do. If you add a TrackingParticipant it can receive information about unhandled errors through a WorkflowInstanceUnhandledExceptionRecord.

If any exception occurs inside any activity, it can be easily catch through inbuilt try catch activity. Put a try catch at the workflow level. If any exception generated, catch them and perform your own tasks.

Related

Enqueueing a message to Azure Storage in an Azure function without changing the output

I have a custom handler written in Go running as an Azure Function. It has an endpoint with two methods:
POST /entities
PUT /entities
It was easy to make my application run as an Azure function: I added "enableForwardingHttpRequest": true to host.json, and it just works.
What I need to achieve: life happened and now I need to enqueue a message when my entities change, so it will trigger another function that uses a queueTrigger to perform some async stuff.
What I tried: The only way I found so far was to disable enableForwardingHttpRequest, and change all my endpoints to accept the Azure Function's raw JSON input and output, and then output a message in one of the fields (as documented here.
It sounds like a huge change to perform something simple... Is there a way I can enqueue a message without having to change all the way my application handles requests?
As per this Github document as of now custom handlers related to go lang in Azure functions having a bug and which need to be fixed.

How to get a response of an Azure Runbook started with webhook?

As I know (and Microsoft is always pointing), Runbooks will help you to do automation progress. Related to the Azure Webhook documents, it's possible to call (start/run) a Runbook, from external application using HTML POST request. and there is some simple response code to determine what is the status of post request, But seems there is no more possibility to get more response from the progress.
Am I searching wrong place and using wrong tool to make automation in Azure Could or there is some ways to send a request to Runnbok and get some response?
Extra Note: I know that it's possible to Call a Runbook from another Runbook using WorkFlow and get some responses, but the problem is if I Start a Runbook using webhook, and if there is no way to get any more response except those simple status codes, then how I can determine what is the result of my first call to do some automation? There should be some ways to get the Final result of a Runbook progress to make a decision for next step, else, Runbooks will be meaningless for automation!
Azure Automation is built as a fire and forget solution. It was the first piece in the event-driven architecture. Where something occurs on one system, and there is a call made to react to that.
The intention is that the runbook itself has all of the logic needed to act on its own behalf. That any further processing is done via that runbook firing another process, that could then go and inspect the output and make decisions based on that.
It does seem counter-intuitive initially - I have previously jumped through all sorts of hoops to make Automation more informative - but once you realise its purpose in the Azure infrastructure intention, it begins to kinda make sense.
If you are specifically looking for something you can fire and get a response from, Azure Functions would be the way to go.

Exception handling in App Insights TelemetryInitializer

I'm adding several custom properties to my AppInsights events using Initialize method of ITelemetryInitializer. Some of them are retrieved from the database or other sources which might fail. The question is, are there any official recommendations from the developers on whether or not a try-catch clause should be included inside of Initialize method?
From what I've observed, throwing an exception inside the method doesn't prevent telemetry from appearing, though the custom properties cannot be seen, as expected. Can I rely on this behaviour? Does it somehow affect performance that I don't handle exceptions manually and let AppInsights' code handle them instead?
It depends, doesn't it. If the telemetry initializer adds multiple custom properties and the first one in line fails with an exception, do you want to try to add the others. If so, put a try/catch around each custom property.
If it is just a single property, or all should not be added as soon as the first one fails then you could choose not to handle the exception. In my opinion however, I would want to have control over the exception propagation and choose for handling them myself. (and maybe ignore them with an empty catch, depending on the situation)
Ignoring them completely may give troubles in the future when the SDK for example is altered to not send the telemetry to App Insights when a telemetry initializer fails with an unhandled exception. At least if you decide to go this route try take a peek in the source code of the SDK to see what happens with the unhandled exception.

How to proper log every exception using OWIN

my question should be quite simple, but unfortunately I had no luck in solving it.
Basically, I have some Web API controllers hosted by OWIN and deployed on Azure.
I really need to track down exceptions that occur in each middleware (for example OAuthAuthorizationServerProvider or SignalR Persistent Connections), but I definitely don't have a clue on how to achieve it.
I tried Elmah, but it doesn't seem to work properly with OWIN due to lacking HttpContext.
I tried using log4net, but I'm only able to log exceptions thrown by Web API Controllers using a custom ExceptionFilterAttribute.. others are ignored.
I tried to define a custom LoggerFactory and to assign it in Startup, using app.SetLoggerFactory(new MyLoggerFactory()),
but exception thrown by other middlewares are not logged.
I tried to get at least a meaningful error message sent to the client, but despite <customErrors mode="Off"/> and <deployment retail="false"/>, Azure refuses to return anything but {"message":"an error has occurred"}.. I tried both Azure Web Sites and Azure Cloud Services.
I saw some cloud alternatives that should work with OWIN, like Elmah.io or Raygun.io, but I don't need their cloud features and it is definitely not worth paying hundreds $ per year just to log some exceptions.
What should be the best way to log any possible exception thrown by my application?
Thanks for your help
have you take a look at this link ? http://www.asp.net/web-api/overview/error-handling/web-api-global-error-handling
Because you can't catch all the exceptions using an exceptionFilter, they propose to use a IExceptionLogger and IExceptionHandler to allow global error handling in Web Api 2.
After that, if it's not fit your need, you can construct an OwinMiddleWare that you will place in first position (before the Authenticate stage), this middleware could :
create a requestId in the header of the response
analyse the response code, before sending response, and if it's not a IsSuccessStatusCode, you could log the exception message to a DB and replace the content of the response to send a simple error message to the client using the requestId (to allow you to find the related exception in your db)
hope this help

Debug an Error in a Custom SharePoint Web Service

I have created a custom SharePoint web service that was deployed to, and successfully tested on, a test environment. Unfortunately, the web service has since stopped working, and I am trying to determine what the error is.
The web service now returns the following error in the SOAP response:
SOAP:server
Server was unable to process request. Object reference not set to an instance of an object.
There have been no changes to the deployed web service, so I am assuming that a more recent deployment has altered the SharePoint configuration. My web service .asmx is deployed to the _vti_bin folder, and the assembly is deployed to the GAC. I can see the WSDL file being displayed when I browse to http://servername:port/_vti_bin/MyCustomWebService.asmx. The web methods in the assembly make use of logging (to the Windows Event log), but no logging is occurring when I try and access the web service, which suggests that the call is not getting as far as entering the web method.
Given the above, can anyone offer any suggestions as to debug this issue?
Thanks. MagicAndi.
Update
I have now realised that when I consume the web service from the endpoint http://servername:port/Site/_vti_bin/MyCustomWebService.asmx, it works, but when I use the endpoint http://servername:port/_vti_bin/MyCustomWebService.asmx, the web service fails as described above. I will update further when I diagnose the cause of the issue.
this is a try catch to get more infomraion on the exception. It will give you more information which will help debug your problem
try {
// Do soap call here
}
catch (System.Web.Protocols.SoapException soap_ex)
{
Console.WriteLine(soap_ex.Detail.OuterXML);
}
catch(System.Exception ex)
{
Console.WriteLine(ex.Message);
}
The easiest option is to attach a debugger set to break on exceptions. If your infrastructure rules don't allow that, you'll probably need to add some additional logging to your code on the server. If you are lucky there may be enough information available in the soap message, but in my experience null reference exceptions usually need more information to be found easily.

Resources