Archive

Archive for the ‘Azure’ Category

Enabling Application Insights on ANY ASP.NET website

October 22, 2017 Leave a comment

1. Install DLL via Nuget

Install-Package Microsoft.ApplicationInsights.Web

2. Add items in bold to the relevant sections in web.config

<system.web>
<httpModules>
     <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
   </httpModules>

<system.webServer>
   <modules>
     <remove name="TelemetryCorrelationHttpModule"/>
     <add name="TelemetryCorrelationHttpModule"
       type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation"
       preCondition="integratedMode,managedHandler"/>
     < remove name="ApplicationInsightsWebTracking"/>
     <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
        preCondition="managedHandler"/>
   </modules>

<system.diagnostics>
  <trace autoflush="true" indentsize="0">
    <listeners>
      <add name="myAppInsightsListener" type="Microsoft.ApplicationInsights.TraceListener.ApplicationInsightsTraceListener, Microsoft.ApplicationInsights.TraceListener" />
    </listeners>
  </trace>
< /system.diagnostics>

3. Create an ApplicationInsights.config file in /

<?xml version="1.0" encoding="utf-8"?>
< ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
 
  < InstrumentationKey>[Your Instrumentation Key]</InstrumentationKey>
  < TelemetryInitializers>
    <Add Type="Microsoft.ApplicationInsights.DependencyCollector.HttpDependenciesParsingTelemetryInitializer, Microsoft.AI.DependencyCollector"/>
    <Add Type="Microsoft.ApplicationInsights.WindowsServer.AzureRoleEnvironmentTelemetryInitializer, Microsoft.AI.WindowsServer"/>
    <Add Type="Microsoft.ApplicationInsights.WindowsServer.AzureWebAppRoleEnvironmentTelemetryInitializer, Microsoft.AI.WindowsServer"/>
    <Add Type="Microsoft.ApplicationInsights.WindowsServer.BuildInfoConfigComponentVersionTelemetryInitializer, Microsoft.AI.WindowsServer"/>
    <Add Type="Microsoft.ApplicationInsights.Web.WebTestTelemetryInitializer, Microsoft.AI.Web"/>
    <Add Type="Microsoft.ApplicationInsights.Web.SyntheticUserAgentTelemetryInitializer, Microsoft.AI.Web">
      <!– Extended list of bots:
             search|spider|crawl|Bot|Monitor|BrowserMob|BingPreview|PagePeeker|WebThumb|URL2PNG|ZooShot|GomezA|Google SketchUp|Read Later|KTXN|KHTE|Keynote|Pingdom|AlwaysOn|zao|borg|oegp|silk|Xenu|zeal|NING|htdig|lycos|slurp|teoma|voila|yahoo|Sogou|CiBra|Nutch|Java|JNLP|Daumoa|Genieo|ichiro|larbin|pompos|Scrapy|snappy|speedy|vortex|favicon|indexer|Riddler|scooter|scraper|scrubby|WhatWeb|WinHTTP|voyager|archiver|Icarus6j|mogimogi|Netvibes|altavista|charlotte|findlinks|Retreiver|TLSProber|WordPress|wsr-agent|http client|Python-urllib|AppEngine-Google|semanticdiscovery|facebookexternalhit|web/snippet|Google-HTTP-Java-Client–>
      <Filters>search|spider|crawl|Bot|Monitor|AlwaysOn</Filters>
    </Add>
    <Add Type="Microsoft.ApplicationInsights.Web.ClientIpHeaderTelemetryInitializer, Microsoft.AI.Web"/>
    <Add Type="Microsoft.ApplicationInsights.Web.OperationNameTelemetryInitializer, Microsoft.AI.Web"/>
    <Add Type="Microsoft.ApplicationInsights.Web.OperationCorrelationTelemetryInitializer, Microsoft.AI.Web"/>
    <Add Type="Microsoft.ApplicationInsights.Web.UserTelemetryInitializer, Microsoft.AI.Web"/>
    <Add Type="Microsoft.ApplicationInsights.Web.AuthenticatedUserIdTelemetryInitializer, Microsoft.AI.Web"/>
    <Add Type="Microsoft.ApplicationInsights.Web.AccountIdTelemetryInitializer, Microsoft.AI.Web"/>
    <Add Type="Microsoft.ApplicationInsights.Web.SessionTelemetryInitializer, Microsoft.AI.Web"/>
  </TelemetryInitializers>
  < TelemetryModules>
     <Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector">
      < ExcludeComponentCorrelationHttpHeadersOnDomains>
         <!–
        Requests to the following hostnames will not be modified by adding correlation headers.
        This is only applicable if Profiler is installed via either StatusMonitor or Azure Extension.
        Add entries here to exclude additional hostnames.
        NOTE: this configuration will be lost upon NuGet upgrade.
        –>
        <Add>core.windows.net</Add>
         <Add>core.chinacloudapi.cn</Add>
        <Add>core.cloudapi.de</Add>
        <Add>core.usgovcloudapi.net</Add>
      </ExcludeComponentCorrelationHttpHeadersOnDomains>
    </Add>
    <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.AI.PerfCounterCollector">
      <!–
      Use the following syntax here to collect additional performance counters:
     
      <Counters>
         <Add PerformanceCounter="\Process(??APP_WIN32_PROC??)\Handle Count" ReportAs="Process handle count" />
        …
      </Counters>
     
      PerformanceCounter must be either \CategoryName(InstanceName)\CounterName or \CategoryName\CounterName
      
      NOTE: performance counters configuration will be lost upon NuGet upgrade.
     
      The following placeholders are supported as InstanceName:
        ??APP_WIN32_PROC?? – instance name of the application process  for Win32 counters.
        ??APP_W3SVC_PROC?? – instance name of the application IIS worker process for IIS/ASP.NET counters.
        ??APP_CLR_PROC?? – instance name of the application CLR process for .NET counters.
       –>
    </Add>
    <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryModule, Microsoft.AI.PerfCounterCollector"/>
    <Add Type="Microsoft.ApplicationInsights.WindowsServer.DeveloperModeWithDebuggerAttachedTelemetryModule, Microsoft.AI.WindowsServer"/>
    <Add Type="Microsoft.ApplicationInsights.WindowsServer.UnhandledExceptionTelemetryModule, Microsoft.AI.WindowsServer"/>
    <Add Type="Microsoft.ApplicationInsights.WindowsServer.UnobservedExceptionTelemetryModule, Microsoft.AI.WindowsServer">
      <!–</Add>
    <Add Type="Microsoft.ApplicationInsights.WindowsServer.FirstChanceExceptionStatisticsTelemetryModule, Microsoft.AI.WindowsServer">–>
    </Add>
    <Add Type="Microsoft.ApplicationInsights.Web.RequestTrackingTelemetryModule, Microsoft.AI.Web">
      <Handlers>
        <!–
        Add entries here to filter out additional handlers:
       
        NOTE: handler configuration will be lost upon NuGet upgrade.
        –>
        <Add>System.Web.Handlers.TransferRequestHandler</Add>
        <Add>Microsoft.VisualStudio.Web.PageInspector.Runtime.Tracing.RequestDataHttpHandler</Add>
        <Add>System.Web.StaticFileHandler</Add>
        <Add>System.Web.Handlers.AssemblyResourceLoader</Add>
         <Add>System.Web.Optimization.BundleHandler</Add>
        <Add>System.Web.Script.Services.ScriptHandlerFactory</Add>
         <Add>System.Web.Handlers.TraceHandler</Add>
        <Add>System.Web.Services.Discovery.DiscoveryRequestHandler</Add>
        <Add>System.Web.HttpDebugHandler</Add>
      </Handlers>
    </Add>
    <Add Type="Microsoft.ApplicationInsights.Web.ExceptionTrackingTelemetryModule, Microsoft.AI.Web"/>
    <Add Type="Microsoft.ApplicationInsights.Web.AspNetDiagnosticTelemetryModule, Microsoft.AI.Web"/>
  </TelemetryModules>
  < TelemetryProcessors>
     <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryProcessor, Microsoft.AI.PerfCounterCollector"/>
    <Add Type="Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor, Microsoft.ApplicationInsights"/>
    <Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
      < MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
      < ExcludedTypes>Event</ExcludedTypes>
    </Add>
    <Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
      <MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
       <IncludedTypes>Event</IncludedTypes>
    </Add>
  </TelemetryProcessors>
  < TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel"/>
< !–
    Learn more about Application Insights configuration with ApplicationInsights.config here:
    http://go.microsoft.com/fwlink/?LinkID=513840
   
    Note: If not present, please add <InstrumentationKey>Your Key</InstrumentationKey> to the top of this file.
  –></ApplicationInsights>

Advertisements
Categories: ASP.NET, Azure

Cloud Shared Notepad–Beta

December 16, 2011 Leave a comment

This is the pre beta version of the cloud shared notepad, its free for all to use (unless it becomes so popular that my azure account starts charging me)

Anyway I acknowledge that there are definitely issues with the GUI, so please bear with me for a while.

Just some points to note

  1. Below the cloudsharenotepad.cloudapp.net/notes is actually a textbox, you have to enter your note url there (in this example it is myurlhere)
  2. You can enter your notify email, I have yet to implement this function, so for now it is purely cosmetic

image

 

Thanks for your support! Smile

Categories: ASP.NET, Azure

Publishing to Windows Azure from Visual Studio 2010

December 16, 2011 Leave a comment

 

Here are the steps to publish to Windows Azure from inside Visual Studio 2010

  1. From inside Visual Studio, right click the Azure project (the icon looks like a blue globe)
  2. image

  3. Click on “Publish”
  4. You will see the screen below
    image
  5. If you have yet to import your publish settings, click on the hyperlink to generate the publishing file
  6. Once you get the file, use the import button to import your settings file
  7. You should now have a subscription available for selection
    image
  8. If you do not have any hosted services, you will see the screen below. Else skip to step 9
    image
  9. Fill in your hosted service name and preferred data centre location and click “OK”.
  10. In the publish settings, make the necessary changes and click “Publish”
  11. Windows Azure Activity Log will appear and you can see the deployment status there. Do take note that this may take quite a while to deploy even for a simple app.
    image
  12. Once it is complete, the status will reflect to show it is completed and you will be able to see the url to your app
    image
    Enjoy!
Categories: ASP.NET, Azure

Azure TableServiceContext presents an error with CreateQuery function

December 16, 2011 2 comments

If you were using azure table storage and found the following error when writing the CreateQuery function

image

does not contain a definition for’ ‘CreateQuery’ and no extension method ‘CreateQuery’ accepting a first argument of type..

 

What is happening is that other than adding Microsoft.WindowsAzure.StorageClient, you aldo need to add System.Data.Services.Client, which Visual Studio actually tells you when you attempt to build the project.

 

Error    1    The type ‘System.Data.Services.Client.DataServiceContext’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘System.Data.Services.Client, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.   

 

Once you added the reference, the error will automatically go away.

 

Now if only there was an easy way to automatically add the missing reference in since Visual Studio knows the exact error and also what should be done..

Categories: ASP.NET, Azure

Windows SQL Azure Firewall

December 15, 2011 2 comments

 

For those who are new to SQL Azure, there are firewall settings that you need to take note of when you first create a SQL Database.

 

By default the firewall is set to block ALL external access

 

So if you wish to enable ALL access (aka disable the firewall), you can use the following settings

image

Categories: Azure, SQL Server

What is this Cloud all about

November 24, 2011 Leave a comment

The cloud term has been used in various forms over the last few Akamai had it with their cached storage, then came google and microsoft with their huge geographically dispersed data centres,and along came facebook.

I’ve never really been a proponent of using the word cloud as i never felt that technology has advanced to such a stage. In the last 2 years, what cloud meant was that you pay for a “cloud” instance and then use it. This was what hosting companies have been doing for the last 5 years via virtual private server (VPS). The difference between VPS and cloud instances is that you are charged for everything you use in the cloud, VPS usually impose a monthly charge.

This to me is just server virtualization, and not a true cloud, there is still server administration that i need to take care of, which is not really what i should be doing.

Recently after getting my hands dirty with Microsoft Azure and new System Centre 2012 and Windows Server 8 offerings, i’m beginning to feel that Microsoft really does know the direction they are going with cloud. No longer is it server virtualization, it lets you host your app and scale your app. It is no longer really about having to do windows update, restarts, worrying about correct installation of the components, securing the server, it is just about my app, and how to make it run smoothly.

 

This i feel is cloud, me as an app owner, managing my app, making it perform as best as it can, and leave the rest to a system that knows very well what it is doing.

Categories: Azure

Azure Access Control Service Part 2 – Prerequisites for development

May 11, 2011 1 comment

In order to start development for ACS, you will need the following

  1. Windows Identity Foundation Runtime
  2. Windows Identity Foundation SDK
  3. Visual Studio 2010

Once installed properly, you will notice a add STS reference option inside Visual Studio when you right click a web application or a website project.

To get the required link, login to your management service portal (https://%5Bnamespace%5D.accesscontrol.windows.net/v2/mgmt/service )

Click on Application integration under Development.

Copy the url for WS-Federation Metadata

Now to add STS to your application

  1. Right click the project and click on “Add STS”
  2. Click Next for the first screen
  3. If you are prompted for something about not secure, ignore and click ok
  4. Select “Use an existing STS”
  5. Paste the link you copied previously into the textbox
  6. Click Next until complete

 

Your website is now configured to use Azure ACS to perform authentication.

To test if its working correctly, add the following code inside your default.aspx.cs

        foreach(var claim in (User.Identity as Microsoft.IdentityModel.Claims.ClaimsIdentity).Claims)
        {
            Response.Write(claim.ClaimType + ” = ” + claim.Value + “<br />”);
        }

In case you wish to know the default claims returned by each provider

Facebook

http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier:
http://schemas.microsoft.com/ws/2008/06/identity/claims/expiration:
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress:
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name:
http://www.facebook.com/claims/AccessToken:
http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider:

Google

http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier:
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress:
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name:
http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider:

LiveID

http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier:
http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider:

If you have noticed, YES for some reason Windows Live only returns quite useless data unlike the other providers, not sure why this is so as this makes it extremely useless.

Yahoo

http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier:
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress:
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name:
http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider:

Categories: ASP.NET, Azure