Using Application Insights in a worker role using OWIN Web API 2

Hi,
Great work, I'm wondering if you had any guidance on using Application Insights with a worker role hosted Web API 2 application using OWIN ?
I'm planning to create a Delegating Handler as you don't have a Begin_Request event to issue the  ServerAnalytics.BeginRequest but anyone thoughts or guidance would be appreciated.
We are planning to try it out over the next few days so I'll report back my findings then.
Thanks
John

You can start with this (just an example, please adjust to your needs):
public class ApplicationInsightsHandler : DelegatingHandler
private TelemetryClient telemetryClient;
public ApplicationInsightsHandler()
this.telemetryClient = new TelemetryClient();
protected override Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request, CancellationToken cancellationToken)
DateTimeOffset start = DateTime.Now;
return base.SendAsync(request, cancellationToken)
.ContinueWith<HttpResponseMessage>((responseToCompleteTask) =>
HttpResponseMessage response = responseToCompleteTask.Result;
int statusCode = (int)response.StatusCode;
this.telemetryClient.TrackRequest(request.RequestUri.AbsolutePath,
start, DateTimeOffset.Now - start,
statusCode.ToString(),
statusCode < 400);
return response;
Anastasia

Similar Messages

  • Autoscaling Application block for Azure worker role console app not working. Get error as The HTTP request was forbidden with client authentication

    I have written a console application to test the WASABi(AutoScaling Application Block) for my worker role running in azure. The worker role processes the messages in the queue and I want to scale-up based on the queue length. I have configured and set the
    constraints and reactive rules properly. I get the following error when I run this application.
    [BEGIN DATA]{}
        DateTime=2013-12-11T21:30:02.5731267Z
    Autoscaling General Verbose: 1002 : Rule match.
    [BEGIN DATA]{"EvaluationId":"4f9f7cb0-fc0d-4276-826f-b6a5f3ea6801","MatchingRules":[{"RuleName":"default","RuleDescription":"The default constraint rule","Targets":["AutoscalingWebRole","AutoscalingWorkerRole"]},{"RuleName":"ScaleUpOnHighWebRole","RuleDescription":"Scale
    up the web role","Targets":[]},{"RuleName":"ScaleDownOnLowWebRole","RuleDescription":"Scale down the web role","Targets":[]},{"RuleName":"ScaleUpOnHighWorkerRole","RuleDescription":"Scale
    up the worker role","Targets":[]},{"RuleName":"ScaleDownOnLowWorkerRole","RuleDescription":"Scale down the worker role","Targets":[]},{"RuleName":"ScaleUpOnQueueMessages","RuleDescription":"Scale
    up the web role","Targets":[]},{"RuleName":"ScaleDownOnQueueMessages","RuleDescription":"Scale down the web role","Targets":[]}]}
        DateTime=2013-12-11T21:31:03.7516260Z
    Autoscaling General Warning: 1004 : Undefined target.
    [BEGIN DATA]{"EvaluationId":"4f9f7cb0-fc0d-4276-826f-b6a5f3ea6801","TargetName":"AutoscalingWebRole"}
        DateTime=2013-12-11T21:31:03.7516260Z
    Autoscaling Updates Verbose: 3001 : The current deployment configuration for a hosted service is about to be checked to determine if a change is required (for role scaling or changes to settings).
    [BEGIN DATA]{"EvaluationId":"4f9f7cb0-fc0d-4276-826f-b6a5f3ea6801","HostedServiceDetails":{"Subscription":"psicloud","HostedService":"rmsazure","DeploymentSlot":"Staging"},"ScaleRequests":{"AutoscalingWorkerRole":{"Min":1,"Max":2,"AbsoluteDelta":0,"RelativeDelta":0,"MatchingRules":"default"}},"SettingChangeRequests":{}}
        DateTime=2013-12-11T21:31:03.7516260Z
    Autoscaling Updates Error: 3010 : Microsoft.Practices.EnterpriseLibrary.WindowsAzure.Autoscaling.ServiceManagement.ServiceManagementClientException: The service configuration could not be retrieved from Windows Azure for hosted service with DNS prefix 'rmsazure'
    in subscription id 'af1e96ad-43aa-4d05-b3f1-0c9d752e6cbb' and deployment slot 'Staging'. ---> System.ServiceModel.Security.MessageSecurityException: The HTTP request was forbidden with client authentication scheme 'Anonymous'. ---> System.Net.WebException:
    The remote server returned an error: (403) Forbidden.
       at System.Net.HttpWebRequest.GetResponse()
       at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
       --- End of inner exception stack trace ---
    Server stack trace: 
       at System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest request, HttpWebResponse response, WebException responseException, HttpChannelFactory`1 factory)
       at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)
       at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
       at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    If anyone know why I am getting this anonymous access violation error. My webrole is secured site but worker role not.
    I appreciate any help.
    Thanks,
    ravi
      

    Hello,
    >>: The service configuration could not be retrieved from Windows Azure for hosted service with DNS prefix 'rmsazure' in subscription id **************
    Base on error message, I guess your azure service didn't get your certificate and other instances didn't have certificate to auto scale. Please check your upload the certificate on your portal management. Also, you could refer to same thread via link(
    http://stackoverflow.com/questions/12843401/azure-autoscaling-block-cannot-find-certificate ).
    Hope it helps.
    Any question or result, please let me know.
    Thanks
    Regards,
    Will 
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Getting error while using HTTP connector and calling POST action to a Web API which is deployed as website on Azure

    I have create Logic App under Azure App Services, I am getting
    error while using HTTP connector and calling POST action to a Web API which is deployed as website on Azure.
    Following are the screen shots:
    Login App Connector Diagram:
    hema

    Marking as answered since no response on request for more information - assuming that you found what was wrong in the inputs. Let us know if you're still having trouble.
    http://twitter.com/joshtwist

  • WCF and WP8.1: Can I only use WCF REST services? Then better WCF or Web API?

    I am trying to create a simple application to test WCF with WP8.1. I have created my service. Later I create my WP8.1 silver light application and I try to add a reference to my service Project. The problem is that I get an error that says that I have only
    add reference to projects that are Windows pone 8.
    I have read some solutions, but all of them are creating a WCF REST service, so my doubt if the WP8.1 applications only can connect to WCF REST services.
    In this case, if this is true, it not would be better to use Web API instead of WCF?
    Thanks so much.

    You can use any type of rest service with windows phone 8.1 because rest services can be called via the httpclient class.  You dont need a service reference.  Personally I prefer the web api but there is no reason you can not use a wcf rest service.

  • Is it possible to do Continuous deployment for azure cloud services(website,web and worker roles) using VSO Release management?

    Hi,
    I am trying to do continuous deployment using visual studio online and release management for Azure cloud services. But not able to find the way to do it(with the help of different blogs, those are describing using VM only).
    I tried using Release management visual studio extension also. But no Luck.
    Please help me if it is possible to do continuous deployment using release management.
    Thanks,
    Phani

    Hi,
     Please refer to the following Forum Thread with similar question which has been answered. Let us know if this helps.
     https://social.msdn.microsoft.com/Forums/en-US/9d8322f6-36e5-4cca-a982-d420d34d2072/realease-management-deployment-to-azure-websites-webworker-roles?forum=tfsbuild
    Regards,
    Nithin Rathnakar

  • When using applications how much usage are you using or are you using none

    ive downloaded some free applications on to my iphone lie (facebook, myspace, webmessenger) when actually usually the applications does that use the usage that i get monthly how does it work.

    Hello Kazza0181,
    As Tamara mentioned, any application that involves access to the Internet to function (and all the applications you mentioned do require Internet access), you are using the phone carrier's data network.
    Since I'm in the U.S. I'm not familiar with the data plans for the carrier in Australia. If your phone plan does not include unlimited data or it has a monthly limit before you are charge extra, your best option is to use WiFi instead of the cellular data network when you're using those applications. If you have WiFi enabled and you are connected to a trusted network (your own or a commercial WiFi hotspot), the iPhone will receive and send data via WiFi. Any data that travels over WiFi will not be reflected in your cellular data plan. Some commercial hotspots have their own charges to join their network, so check with the staff of the location providing the WiFi access for information on how to join their network and what charges may apply.
    Tips for using a WiFi network can be found here:
    http://support.apple.com/kb/TS1398
    Also, see page 100 of the User's Guide:
    http://manuals.info.apple.com/enUS/iPhone_UserGuide.pdf
    Hope that helps,
    Charles H.

  • HELP QUICK!  My iPad is restricting me from using YouTube, when I used my friend's theirs worked perfectly (using my wifi) and when I try again to use mine at home it doesn't work. help me please!

    Dear reader,
    Could you please help me quick, my iPad is restricting me from something.
    I tried to go on YouTube many times on my favorite videos list and I get a message saying: you don't have permission to access the requested resource. I go to settings to see if anybody restricted me from YouTube and nobody did. I went to my friend's house and they have wifi. My iPad worked perfectly in YouTube. I went back to use my dad's iPad and after I watched some videos for a while, his stopped working on YouTube too. After then, I went back to my mom's house and the same thing happened. TO BOTH MY IPAD AND MY DAD'S! Is there something wrong with them? Please reply soon! :)

    I have the same issue. When I select a video from my favorites list (this is in the YouTube app—not through the Safari browser), I get the error message "You do not have permission to access the requested resource." My sister has said she has gotten the same message on her iPhone 3GS.
    The work around is to kill the YouTube process (double press the home key to bring up the recent apps list, press and hold on the YouTube icon until the red minus sign appears, then tap on the minus sign). When you restart YouTube, it works.
    However, invariably, the next day, when I try again, I get the same message, and have to kill YouTube again.

  • Can't access my DVR manager using Firefox 4...works fine using Firefox 3.6.16. Why

    Does works for either Win or Mac versions of Firefox 4

    I had the same problem in linux and after trying out new profile manager app (https://developer.mozilla.org/en/Profile_Manager) i tried the switch -no-remote and got it working ;)
    for example: firefox -p invented -no-remote
    PS: profile invented does not exist :P

  • CANNOT LOAD FIREFOX-LOOKING FOR PERMISSIONS-GIVES 2 CHOICES 1)USE CURRENT USER-(DOESN'T WORK) 2)USE -ADMINISTRATOR-ASKES FOR PASSWORD (I HAVE NO PASWORD) CAN I BE HELPED

    cannot load firefox. goes thru the run process,that asks for current user or administrator.i click current and it just diappears.the second choice gives me a user name(ADMINISTRATOR). won't accept anything i put in as a password.

    Check that you do not run Firefox as Administrator.<br />
    Right-click the Firefox desktop shortcut and choose "Properties".<br />
    In the Compatibility tab, make sure that Privilege Level: "Run this program as Administrator" is not selected.<br />
    Also check your security software.<br />
    Remove all rules for Firefox from the permissions list in the firewall and let your firewall ask again for permission to get full unrestricted access to internet for Firefox and the plugin-container process.
    See:
    * [[Server not found]]
    * [[Firewalls]]
    * http://kb.mozillazine.org/Browser_will_not_start_up

  • Getting Timeout Error when running web performance Webtest using App-Insights

    Hi All,
    I have created web performance test using VSTS 2013. When I am running this test using App-Insights (Azure Version) I am getting error "Web Test exceeded the configured timeout (00:02:00) and was aborted." In webtest property I set timeout limit
    is 300 Sec. still webtest is timeout in 2 min. Kindly let me know Is this problem of App-Insights (Azure Version) or webtest?
    Regards,
    Sandip

    Sandip, Application Insights (both the Azure and VSO versions) override the timeout internally to a max of 2 minutes. No web tests in AI can run for longer than 2 minutes.
    This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm

  • Application Insights for load testing in VS 2013, Azure Preview or Visual Studio Online?

    I'm trying to get some clarification on which version of application insights to use to get performance counters from application insights for my azure cloud service for load and performance testing purposes. 
    So far, its not be clear what the differences between the two versions are, after deploying first the Azure Preview version, I attempted to set up performance counters using application insights but was shown an error because my visual studio online account
    did not have an associated application insights instance. 
    Is it possible to get performance counters using AI for load testing using the Azure Preview version? If so, how? If not, is that planned as a new feature or will performance counters for VSO cloud based load testing have to be used when support for the
    VSO version of application insights is eventually dropped? 
    Thanks, 
    Luke

    Hi Alex, thanks for your response. I do have an Azure account, and have tinkered with AI in Azure Preview. My question was more about what the differences between the VSO and azure preview versions of AI are. 
    When I initially deployed AI to the azure portal and tried to run load tests from visual studio (cloud load tests, that is) I could not. Its possible I had made a mistake in configuring the azure version of application insights though. Strangely enough,
    I actually do still see application insights data in the azure preview portal after I removed the newer AI version and installed AI 1.3. 
    To clarify my question, is it or will it be possible to run cloud based load tests (using visual studio online or another integrated service) against a azure web role deployed with application insights for azure and get performance counters of the system
    under test via AI? To do that, will I also have an application insights application in the visual studio online account (similar to how I do now with the VSO version of AI), because that seems to be a requirement to load performance counters from application
    insights within visual studio. 
    Thanks and sorry if I misunderstood your answer. 

  • Worker Role Hosting

    I am a beginner in azure, so i implemented a worker role and host it on cloud through visual studio 2013 with remote machine enabled. after hosting i logged into that instance, i find the folder of worker role but no IIS hosting no service so how the worker
    role is actually hosted in that machine.

    Hi,
    A worker role is a role that is useful for generalized development, and may perform background processing for a web role. When you have a need for a background process that performs long running or intermittent tasks, you should use this role.
    Worker Role is a part of Compute however does not run IIS.
    Some of the differences between a Web Role and a Worker Role are:
    The web role provides support for presenting a user facing frontend through IIS. While you can write code to present a user interface using a worker role, the web role makes creating this type of application easier.
    In the web role, IIS handles the efficiency of threading. In the worker role you must handle threading issues yourself.
    You must provide a run method that is called to initiate processing.
    The security perimeter is different between the web and worker role. In the web role the access control lists (ACLs) for certificates are set to support IIS and network services by default. When using a worker role you must set the ACLs to support the permissions
    your application requires.
    The types of tasks a worker role is typically used are:
    Long running tasks that are asynchronous that the user does not have to wait for.
    To host application services that do not require a user interface.
    Background services listening to a queue.
    Running TCP based services.
    Compute intensive jobs.
    To know more about creating Worker Role, you might want to follow the below article
    http://windowsazure4beginner.com/Tutorial/Hello-World-Application.html
    Hope this helps !
    Regards,
    Sowmya

  • How to move worker roles to VM?

    I've developed an app that has 3 worker roles and a web role.  The client has decided that they want to put this on a VM.  I understand how to handle the web role but I am unclear how I convert the worker roles.  I've searched but I can't
    find anything that directly guides me on what's needed.  Does anyone know of a link that would show me how to convert over?

    The easiest way to develop a Windows Service in my opinion is using
    Topshelf.
    You can convert your Worker Role code across pretty easily by
    calling the Run code from the WhenStarted event, the OnStop code from the WhenStopped event and the OnStart code from the constructor of your service class.
    Alternatively, you can
    inherit the ServiceControl interface and implement the Start and Stop methods.
    Deploying the service is easy too. Simply get the built files from your console app (a Topshelf service is simply a console app) and
    invoke the app (e.g. PowerShell script) with the install parameter, then again with the start parameter.

  • Async / Await in Cloud Services Worker Roles?

    Good evening,
    I was wondering if and how one would be able to utilize async / await for Azure Cloud Services' Worker Roles? Basically I have background jobs that will/shall run on worker roles, however many of those are performing up/downloads from Azure Storage blobs
    and ideally I'd like to await those calls.
    So is async/await natively supported for CS Worker Roles (using Azure SDK 2.5) and if so, how? And if not.. is it planned at all?
    Thanks,
    -Jörg

    Hi,
    I would suggest you have a look at this thread:
    http://stackoverflow.com/questions/15991287/async-await-in-azure-worker-role-causing-the-role-to-recycle
    A simple solution is to just do this:
    public override void Run()
    RunAsync().Wait();
    public async Task RunAsync()
    while (true)
    await Task.Delay(60000);
    Hope this helps.
    Best Regards,
    Jambor
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Worker role scale up and down manually

    I have specific task that need to be done on random time (i cannot predict when). one task can take more than 5 min.
    To be "cloud" compatible and "elasctic" ready, i don't want to have only 1 instance of this worker role but more dynamically when needed.
    I ve created a "queue" with all the task that need to be done, because it was the solution i thoguth with the auto scalling of azure
    But when i try to put it in place, my problem are the following :
    1)with the auto scalling of worker role, it seems it doesn't start to evaluate directly and wait maybe 20 min before scale up the first time. it's not fully ok for me and i would like to have scaling directly.
    2) one instance cannot be killed like this. The task can take more than 5 min ! (maybe 10 or 15). And in this case it's a big issue for me if one instance is randomly dropped. And i cannot can "put" somewhere the current data of the task to be proceeded
    by someone else
    My idea is that my instance "0" create other instance if it see that the number of task on the queue is big
    AND, it's the instance created (so not the 0!) that kill itself when he has finished and see there is nothing else to do
    Is it possible ? I don't find documentation about that.

    Hi,
    If you use auto scaling add a worker role, it spend 20 min before scale up the first time, this 20 min may be used to build azure worker role instance. so we need a metrics to let worker role prepared in advance, for example, in the case of Cloud services,
    if CPU exceeds a defined threshold in your rule, auto scaling will add additional instances to handle the increased load.  When CPU drops below a defined threshold, auto scaling will remove those extra instances.  It’s this kind of elasticity that
    makes cloud computing so compelling.
     See more at:http://rickrainey.com/2013/12/15/auto-scaling-cloud-services-on-cpu-percentage-with-the-windows-azure-monitoring-services-management-library/
    Best Regards
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for

  • Help! Need to get rid of MacKeeper and Spinning Wheel!

    Hello Apple Community, I have a problem that has been solved by one member of the community, however, I am still having the same problem.  I thought I knew my mac pretty well however, I was one of those stupid people who installed MacKeeper in hopes

  • Few of my amount_cr lines are missing from the query, check GL_JE_LINES_V.

    I have a discover report which have 5 union all, and one of the select statement brings the information about the cr.type like 'MISC'from the table called ar.ar_cash_receipts_all cr. This query basically brings the information of amount_dr and amount

  • Acrobat Pro 9 IAC Detect Corrupt File (TIFF)

    I am trying to convert a huge number of tif files into pdf files, and most of the time the code below works fine, using the IAC to control Acrobat. try CAcroAVDoc avDoc = new AcroAVDocClass(); avDoc.Open(@"D:\Bad Files\file1.TIF", ""); CAcroPDDoc pdD

  • Custom item field in POWL

    Hi all, I've added an item custom field in POWL following this steps: - Add the field to structure /SAPSRM/S_SEARCHFIELDS. (with the same name that it have in st. INCL_EEW_PD_ITEM_CSF_CTR ) - Add the field in view /SAPSRM/V_SRC_CR. - Add the field in

  • Finder constantly refreshing and coming to front (Mavericks - Mac mini)

    I am facing this problem and I do not how to solve it. Could you please give me a hand? Thanks in advanced. Álvaro