<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[Nibras Manna Tech Monologue]]></title><description><![CDATA[This blog will capture my thoughts, notes, and any details I think are useful to share with other developers as I'm learning new technologies]]></description><link>http://www.nibrasmanna.com/</link><generator>Ghost 0.8</generator><lastBuildDate>Wed, 29 Apr 2026 00:22:46 GMT</lastBuildDate><atom:link href="http://www.nibrasmanna.com/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Send Azure outage notifications to Microsoft Teams]]></title><description><![CDATA[<p>If you use Azure services for your mission critical apps, you will want to know when Azure is having an outage that affects you. The Azure <a href="https://azure.microsoft.com/en-us/status/">health status page</a> is pretty much useless since it usually gets updated hours after an outage occurs. The outage has to affect a large</p>]]></description><link>http://www.nibrasmanna.com/send-azure-outage-notifications-to-microsoft-teams/</link><guid isPermaLink="false">7f5cd4ef-2096-479d-b4ab-5e122a6bc029</guid><category><![CDATA[azure]]></category><category><![CDATA[microsoft-teams]]></category><category><![CDATA[azure-monitor]]></category><dc:creator><![CDATA[Nibras Manna]]></dc:creator><pubDate>Fri, 07 Jul 2017 18:33:51 GMT</pubDate><media:content url="http://www.nibrasmanna.com/content/images/2017/07/azure-status-11.png" medium="image"/><content:encoded><![CDATA[<img src="http://www.nibrasmanna.com/content/images/2017/07/azure-status-11.png" alt="Send Azure outage notifications to Microsoft Teams"><p>If you use Azure services for your mission critical apps, you will want to know when Azure is having an outage that affects you. The Azure <a href="https://azure.microsoft.com/en-us/status/">health status page</a> is pretty much useless since it usually gets updated hours after an outage occurs. The outage has to affect a large enough percentage of users before it gets reported on the main health status page. There is nothing more frustrating when <em>you know for a fact</em> that there is an outage affecting your apps, only to see the health status page report that "all services are operating normally". This is where <a href="https://azure.microsoft.com/en-us/services/monitor/">Azure Monitor</a> comes in. Azure Monitor promises to alert you sooner and only for outages that affect your subscription which is pretty helpful since I don't care about outages in services/datacenters that I don't use. </p>

<h4 id="setup">Setup</h4>

<p>In the Azure portal, go to the <a href="https://portal.azure.com/#blade/Microsoft_Azure_Monitoring/AzureMonitoringBrowseBlade/events">Monitor blade</a>, select Alerts, then Add activity log alert. You should see something like this:</p>

<p><img src="http://www.nibrasmanna.com/content/images/2017/07/alert-1.png" alt="Send Azure outage notifications to Microsoft Teams"></p>

<p>For alert criteria, make sure to choose Service Health. In this case, I'm interested in all alert types and levels under the Service Health category. </p>

<p>Under alert actions, the most straightforward options are SMS and email. But in this case, we want to forward these alerts to a Microsoft Teams channel for greater visibility within the organization. This is possible by using the Webhook option. To do this, we can provision a Function or Logic app to consume the Webhook payload, then forward that to a Teams channel of our choosing (or even Slack). That's too much work though. Thankfully, Microsoft Teams lets you send a message to a specific channel via email. We'll use this option instead since its a lot easier. Just go to the channel you want the alerts to go to, click on the three dots next to the channel's name and select "Get email address". </p>

<p><img src="http://www.nibrasmanna.com/content/images/2017/07/teams-channel-email.png" alt="Send Azure outage notifications to Microsoft Teams"></p>

<p>Simply copy and paste this email in the alert form using the email option. That's it! With very little setup, you will now get alerted in Teams for outages that affect your services. This will hopefully help you respond to outages in a more timely manner.</p>

<h4 id="furtherresources">Further resources</h4>

<ul>
<li><a href="https://docs.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-overview-azure-monitor">Azure Monitor documentation</a></li>
<li><a href="https://channel9.msdn.com/Shows/Azure-Friday/Azure-Monitor-Notifications?term=azure%20monitor">Azure Monitor Notifications (Channel 9 video)</a></li>
</ul>]]></content:encoded></item><item><title><![CDATA[Forwarding Azure infrastructure alerts to Slack]]></title><description><![CDATA[<p>My team at Shift Digital uses Azure for all of our computing needs. We do not have a single on-premises server. We use both Infrastructure as a Service (IaaS) and Platform as a Service (PaaS). Because all of infrastructure lives in the cloud, we needed a way to get alerts</p>]]></description><link>http://www.nibrasmanna.com/forwarding-azure-infrastructure-alerts-to-slack/</link><guid isPermaLink="false">5b32ceb3-f57c-498f-b32d-be763b4ff095</guid><category><![CDATA[azure]]></category><category><![CDATA[slack]]></category><dc:creator><![CDATA[Nibras Manna]]></dc:creator><pubDate>Sun, 23 Apr 2017 16:55:18 GMT</pubDate><content:encoded><![CDATA[<p>My team at Shift Digital uses Azure for all of our computing needs. We do not have a single on-premises server. We use both Infrastructure as a Service (IaaS) and Platform as a Service (PaaS). Because all of infrastructure lives in the cloud, we needed a way to get alerts in case of high CPU usage, high memory usage, ... etc... Email notifications are ok but not preferable because Slack is our main method of communication. After some research, we found an easy way to forward notifications from Azure to Slack.</p>

<p>I found this <a href="https://github.com/Azure/azure-quickstart-templates/tree/master/201-alert-to-slack-with-logic-app">logic app template</a> that has steps to receive a Webhook from an Azure resource, and forward that notification to a Slack channel of our choosing. Setting up the logic app is very easy. All we need to do is click the Deploy to Azure button, fill out the details of the logic app, and select which Slack channel we want the alerts to go to.</p>

<p><img src="http://www.nibrasmanna.com/content/images/2017/04/azure-slack-notifier--Small-.png" alt=""></p>

<p>Once the logic app is deployed, we will need to authorize it to talk to our Slack account. Edit the logic app and go to the Slack step. Simply login with your Slack credentials and the app is good to go.</p>

<p>We will get a URL that we need to use in our Azure resources.</p>

<p><img src="http://www.nibrasmanna.com/content/images/2017/04/url-1.png" alt=""></p>

<p>Simply copy and paste this URL in the Webhook section of any Azure alert. <br>
<img src="http://www.nibrasmanna.com/content/images/2017/04/azure-alert-rule--Small-.png" alt=""></p>

<p>Now each time this alert fires, we get a notification forwarded to Slack! These alerts do not have to be only from Azure infrastructure. We can also have alerts based on Application Insights custom metrics. For example, we have alerts based on custom events in Application Insights that alert us when a certain metric exceeds a threshold we set (<a href="http://www.nibrasmanna.com/application-insights-custom-events/">I explain this in more detail here</a>).</p>

<p><strong>Note:</strong> By default, the logic app template creates its own App Service Plan and sets it up in the consumption model where you pay per invocation. In our case, we already have an App Service Plan that we want this logic app to run on. Fortunately, there's a way to change the logic app to use an existing plan so we're not paying anything extra. Simply run this PowerShell script. </p>

<pre><code>Param(  
    #the target app service resource group
    [string] $AppService_RG = 'YourResourceGroupNameGoesHere',
    #the target app service name
    [string] $AppService_Name = 'AppServicePlanYouWantTheLogicApppToRunOn',
    #the logic app's resource group
    [string] $LogicApp_RG = 'YourResourceGroupNameGoesHere',
    #the name of the logic app
    [string] $LogicApp_Name = 'YourLogicAppNameGoesHere',
    #the subscription id
    [string] $subscriptionId = 'YourSubIdGoesHere'
)

Login-AzureRmAccount  
$subscription = Get-AzureRmSubscription -SubscriptionId $subscriptionId
Set-AzureRmContext -SubscriptionId $subscriptionId  
$appserviceplan = Get-AzureRmResource -ResourceType "Microsoft.Web/serverFarms" -ResourceGroupName $AppService_RG -ResourceName $AppService_Name
$logicapp = Get-AzureRmResource -ResourceType "Microsoft.Logic/workflows" -ResourceGroupName $LogicApp_RG -ResourceName $LogicApp_Name

$sku = @{
    "name" = $appservicePlan.Sku.tier;
    "plan" = @{
      "id" = $appserviceplan.ResourceId;
      "type" = "Microsoft.Web/ServerFarms";
      "name" = $appserviceplan.Name  
    }
}

$updatedProperties = $logicapp.Properties | Add-Member @{sku = $sku;} -PassThru -Force

$updatedLA = Set-AzureRmResource -ResourceId $logicapp.ResourceId -Properties $updatedProperties -ApiVersion 2015-08-01-preview

Write-Output "Logic App now associated with App Service Plan: $appserviceplan.Name"  
</code></pre>]]></content:encoded></item><item><title><![CDATA[Using Application Insights to track domain related events]]></title><description><![CDATA[<h2 id="overview">Overview</h2>

<p><a href="https://azure.microsoft.com/en-us/services/application-insights/">Application Insights</a> is an Azure offering that helps developers gain insight into their applications as far as exceptions, page views, response times..etc. However, one less known use case of Application Insights is the ability to track domain related events.</p>

<p>My team and I at <a href="http://www.nibrasmanna.com/application-insights-custom-events/www.shiftdigital.com">Shift Digital</a> work on</p>]]></description><link>http://www.nibrasmanna.com/application-insights-custom-events/</link><guid isPermaLink="false">e18bc121-983f-447a-8a5f-8c05abe882c5</guid><category><![CDATA[azure]]></category><category><![CDATA[application-insights]]></category><dc:creator><![CDATA[Nibras Manna]]></dc:creator><pubDate>Wed, 28 Sep 2016 01:54:00 GMT</pubDate><media:content url="http://www.nibrasmanna.com/content/images/2016/07/Insight.jpg" medium="image"/><content:encoded><![CDATA[<h2 id="overview">Overview</h2>

<img src="http://www.nibrasmanna.com/content/images/2016/07/Insight.jpg" alt="Using Application Insights to track domain related events"><p><a href="https://azure.microsoft.com/en-us/services/application-insights/">Application Insights</a> is an Azure offering that helps developers gain insight into their applications as far as exceptions, page views, response times..etc. However, one less known use case of Application Insights is the ability to track domain related events.</p>

<p>My team and I at <a href="http://www.nibrasmanna.com/application-insights-custom-events/www.shiftdigital.com">Shift Digital</a> work on Enterprise Lead Management Systems for automotive OEMs and other clients. Our systems accept leads from a variety of sources and delivers them to dealerships. We recently started using Application Insights to keep a close eye on what's happening within our systems. This helped us get better visibility on exceptions, response times, etc.. but we soon discovered how we can use the <a href="https://azure.microsoft.com/en-us/documentation/articles/app-insights-api-custom-events-metrics/">custom events feature</a> of Application Insights to track domain-related telemetry.</p>

<p>For example, we wanted to know the number of leads we are getting in real time. How many leads are accepted? How many are rejected? We never had that near real time insight into our application before. So with a few lines of code.. we were able to generate graphs like these: <br>
<img src="http://www.nibrasmanna.com/content/images/2016/09/AI-graph.png" alt="Using Application Insights to track domain related events"></p>

<p><img src="http://www.nibrasmanna.com/content/images/2016/09/AI-graph-processing-times.png" alt="Using Application Insights to track domain related events"></p>

<h2 id="thecode">The code</h2>

<p>To make this possible, we simply track a <em>custom event</em> with <em>properties</em> and <em>metrics</em> as shown below:</p>

<p>Note: we first need to install the <a href="https://www.nuget.org/packages/Microsoft.ApplicationInsights/">Microsoft.ApplicationInsights</a> Nuget package  </p>

<pre><code class="language- ">PM&gt; Install-Package Microsoft.ApplicationInsights  
</code></pre>

<pre><code>//capture received time
var receivedTime = DateTime.Now();

//initialize telemetry client
var telemetryClient = new TelemetryClient();  
telemetryClient.Context.InstrumentationKey = "your telemetry key";  
telemetryClient.Context.Operation.Name = "LeadProcessing";

//do the actual work
...

//calculate how long it took to do the work
var processingTime = DateTime.Now.Subtract(receivedTime).TotalSeconds;

//track the event
var properties = new Dictionary&lt;string, string&gt;  
{
   { "Source", "the source of the lead" }
};

var metrics = new Dictionary&lt;string, double&gt;  
{ 
  { "LeadProcessingTime", processingTime } 
};

telemetryClient.TrackEvent("LeadProcessed", properties, metrics);  
</code></pre>

<p>The event being tracked here is <em>"LeadProcessed"</em>. In addition to the event itself, we can also pass properties and metrics. Properties help when <em>filtering</em> and searching for events. For example, we are tracking the source of the lead so we can break leads by source when reporting on that event. On the other hand, metrics let us <em>measure</em> aspects related to the event. In our case, we are measuring how long it took us to process the lead. Both properties and metrics are optional.</p>

<h2 id="reportingonevents">Reporting on events</h2>

<p>The easiest way I've found to generate these graphs is to pin an empty graph to an Azure dashboard, then customizing it. I turn grouping on by event name, then filter out any events I don't want. </p>

<p><img src="http://www.nibrasmanna.com/content/images/2016/09/AI-chart-1.png" alt="Using Application Insights to track domain related events"></p>

<p>Another way to report on these events is by using the <a href="https://blogs.msdn.microsoft.com/bharry/2016/03/28/introducing-application-analytics/">Analytics feature</a> of Application Insights where you can write custom queries to drill into the exact events we want to report on. For example, if we want a pie chart to visualize how many leads were processed versus rejected in the last day, we can write the following query:</p>

<pre><code>customEvents  
| where name == "LeadProcessed"  or  name == "LeadRejected" and timestamp &lt;= ago(1d) 
| render piechart   
</code></pre>

<p>which gives us the following graph: <br>
<img src="http://www.nibrasmanna.com/content/images/2016/09/AI-accepteed-vs-rejected-leads.png" alt="Using Application Insights to track domain related events"></p>

<p>The Analytics tool uses a special query syntax that combines pipes, lots of helper methods, and intellisense to make querying data easier. These graphs can easily be pinned to an Azure dashboard which is nice.</p>

<h2 id="alertsforcustomeventswithmetrics">Alerts for custom events with metrics</h2>

<p>We can even set up alerts for metrics in our custom events. For example, if we want to be alerted when LeadProcessingTime exceeds a certain threshold, all we have to do is add an alert rule to the Application Insights resource like this: <br>
<img src="http://www.nibrasmanna.com/content/images/2016/09/AI---alert.png" alt="Using Application Insights to track domain related events"></p>

<p>Now every time this metric exceeds our threshold for 15 minutes, we get an email alert. We can also specify a <a href="https://azure.microsoft.com/en-us/documentation/articles/insights-webhooks-alerts/">Webhook</a> to be invoked if we want to forward this alert to Slack or HipChat for example. Neat! </p>

<h2 id="conclusion">Conclusion</h2>

<p>Application Insights is a powerful tool that can help us get real-time insight into domain events happening within our application. We saw above how we were able to generate useful graphs with minimal effort and zero UI work. Using this tool will help us diagnose and prevent potential issues before they become problems.</p>

<h2 id="additionalresources">Additional Resources</h2>

<p><a href="https://azure.microsoft.com/en-us/documentation/services/application-insights/">Azure documentation</a> <br>
<a href="https://azure.microsoft.com/en-us/documentation/articles/app-insights-api-custom-events-metrics/">Custom Events in more detail</a> <br>
<a href="https://azure.microsoft.com/en-us/documentation/articles/app-insights-overview/">Detailed walkthrough</a> <br>
<a href="https://github.com/Microsoft/ApplicationInsights-Home/">Official GitHub Repository</a></p>

<p>Disclaimer: The data used to generate graphs in this post is test data for the purpose of demonstration only and does not reflect production values.</p>]]></content:encoded></item><item><title><![CDATA[Azure WebJobs]]></title><description><![CDATA[<blockquote>
  <p>This post is meant to get you up to speed with WebJobs as quickly as possible. It does not however contain every detail about this topic. I've included a few links at the end which contain much more detail. </p>
</blockquote>

<h2 id="overview">Overview</h2>

<p>A WebJob in the context of an Azure WebApp is</p>]]></description><link>http://www.nibrasmanna.com/webjobs/</link><guid isPermaLink="false">eed87c96-c258-4978-a41c-cea3d3118957</guid><category><![CDATA[azure]]></category><category><![CDATA[webjobs]]></category><dc:creator><![CDATA[Nibras Manna]]></dc:creator><pubDate>Wed, 20 Jul 2016 03:11:00 GMT</pubDate><media:content url="http://www.nibrasmanna.com/content/images/2016/07/default_signin_illustration.png" medium="image"/><content:encoded><![CDATA[<blockquote>
  <img src="http://www.nibrasmanna.com/content/images/2016/07/default_signin_illustration.png" alt="Azure WebJobs"><p>This post is meant to get you up to speed with WebJobs as quickly as possible. It does not however contain every detail about this topic. I've included a few links at the end which contain much more detail. </p>
</blockquote>

<h2 id="overview">Overview</h2>

<p>A WebJob in the context of an Azure WebApp is a mechanism for running background processes.  This can be useful in cases where a user completes a task via the WebApp which requires some processing, but that processing does not need to be carried out immediately. WebJobs are a good fit for any asynchronous task such as reacting to events, processing messages from queues, or performing maintenance work.</p>

<h2 id="whywebjobs">Why WebJobs?</h2>

<p>Aren't they just glorified console apps? <em>Not really</em>. WebJobs provide several advantages over console apps. Some of these advantages are:  </p>

<ul>
<li><strong>Logging</strong>: just link your <a href="https://azure.microsoft.com/en-us/services/storage/">Azure Storage</a> account and you'll get a decent logging dashboard in no time.  </li>
<li><strong>Scaling</strong>: if your WebJob experiences high load, the <a href="https://azure.microsoft.com/en-us/services/app-service/">AppService</a> underneath it can be configured to <a href="https://azure.microsoft.com/en-us/documentation/articles/web-sites-scale/">AutoScale</a>. No need to manually deploy and manage additional instances of your job to more virtual machines.  </li>
<li><strong>REST API</strong>: programmatically control your WebJobs through a <a href="https://github.com/projectkudu/kudu/wiki/WebJobs-API">REST API</a>. This is much easier than using RDP especially if you want to manage your WebJobs in code.</li>
<li><strong>WebJobs SDK</strong>: the <a href="https://azure.microsoft.com/en-us/documentation/articles/websites-dotnet-webjobs-sdk/">SDK</a> has many out of the box integrations with <a href="https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-queues/">Azure Storage queues</a>, <a href="https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/">Blob Storage</a>, <a href="https://azure.microsoft.com/en-us/documentation/articles/service-bus-dotnet-get-started-with-queues/">ServiceBus queues</a> and <a href="https://azure.microsoft.com/en-us/documentation/articles/service-bus-dotnet-how-to-use-topics-subscriptions/">topics</a>, and <a href="https://github.com/Azure/azure-webjobs-sdk-extensions">many more</a>. You can of course implement this on your own, but being able to get up and running quickly can be very helpful.</li>
<li><strong>Scheduling</strong>: WebJobs can be scheduled easily using several methods (<a href="http://www.nibrasmanna.com/webjobs/#logs">more on this later</a>)</li>
</ul>

<h2 id="whennottousewebjobs">When not to use WebJobs</h2>

<p>If your code has a dependency on specific software that needs to be installed on the host virtual machine, then using WebJobs might not work for you. With WebJobs, you don't have direct control over the virtual machine they run on. Even in this case, I suggest finding Nuget packages that perform the same job instead of depending on other processes to be present on the host virtual machine.</p>

<h2 id="typesofwebjobs">Types of WebJobs</h2>

<p>There are 3 types of WebJobs</p>

<ul>
<li><strong>Triggered</strong>: runs on a schedule</li>
<li><strong>On Demand</strong>: run manually</li>
<li><strong>Continuous</strong>: runs continuously </li>
</ul>

<p>Continuous WebJobs are a good fit for reacting to events such as processing messages from queues or reacting to file changes in Blob Storage..etc. Triggered and On Demand WebJobs are good for any background processing tasks.  </p>

<h2 id="creatingdeployingwebjobs">Creating &amp; Deploying WebJobs</h2>

<p>A WebJob runs in the context of an Azure WebApp or API App. The WebApp acts as the container for the WebJob. If you have an existing Console App, you can zip and upload it through the Azure portal or deploy it through Visual Studio by right clicking on the project and selecting "<em>Publish as Azure WebJob</em>".</p>

<h6 id="bestpracticeswhencreatinganewwebjob">Best practices when creating a new WebJob:</h6>

<ul>
<li>Add a new project to your solution. You can find the WebJob template under Cloud => Azure WebJob. <em>Note</em>: Make sure you specify the .NET version you want to use. <em>(assuming you're using Visual Studio)</em></li>
</ul>

<p><img src="http://www.nibrasmanna.com/content/images/2016/07/1.png" alt="Azure WebJobs"></p>

<ul>
<li>Update nuget packages as necessary since the template has old verisons. </li>
<li>If you want to deploy to multiple environments (staging, production..etc), add the <a href="https://www.nuget.org/packages/SlowCheetah">SlowCheetah Nuget package</a> (you will need that for transforming app configs).</li>
<li>Add configuration transforms to your app.config. You can do that by right clicking on your app.config file and selecting the <em>"Add Transform"</em> option. <em>Note</em>: you will need the <a href="https://visualstudiogallery.msdn.microsoft.com/69023d00-a4f9-4a34-a6cd-7e854ba318b5">SlowCheetah Visual Studio extention</a> for this option to be available.</li>
<li>When you're ready to publish your WebJob, right click on it and choose "<em>Publish as Azure WebJob</em>". A publishing wizard will guide you through to choose the type and schedule of your WebJob.</li>
<li>Once your WebJob is deployed to Azure, you can find it under the WebApp or API App it was deployed to by going to Settings => WebJobs.</li>
</ul>

<h2 id="schedulingoptions">Scheduling Options</h2>

<p>There are three ways you can schedule your triggered WebJobs </p>

<ul>
<li><a href="https://azure.microsoft.com/en-us/services/scheduler/">Azure Scheduler</a></li>
<li>CRON timer expressions using the <a href="https://github.com/Azure/azure-webjobs-sdk-extensions">WebJobs SDK Extensions Nuget package</a></li>
<li>CRON expression in a <em>settings.job</em> file in the root directory of the WebJob</li>
</ul>

<p>If you decide to use CRON expressions, make sure the <em>Always On</em> option on the web app is turned on.</p>

<p><strong>Note</strong>: if you need scheduling recurrence down to the <em>minute</em>  level, you will need to upgrade the Azure Scheduler instance to the <a href="https://azure.microsoft.com/en-us/pricing/details/scheduler/">Standard tier</a>. </p>

<h2 id="logs">Logs</h2>

<p>WebJobs provide a dashboard where you can see all the jobs you have, their running status, and individual invocations along with any output they generate. </p>

<p><img src="http://www.nibrasmanna.com/content/images/2017/04/19webjobslistinjobsdashboard.png" alt="Azure WebJobs"></p>

<p>In order to access the logs for a WebJob, an <a href="https://azure.microsoft.com/en-us/services/storage/">Azure Storage Account</a> needs to be linked with the WebJob. In App.config, there are two connection strings:  </p>

<pre><code>&lt;add name="AzureWebJobsDashboard" connectionString="" /&gt;  
&lt;add name="AzureWebJobsStorage" connectionString="" /&gt;  
</code></pre>

<p>You can populate these with the connection string for your Storage Account using this format:  </p>

<pre><code>DefaultEndpointsProtocol=https;AccountName=NAME;AccountKey=KEY  
</code></pre>

<p><strong>Important</strong>: On the WebApp you deployed the WebJob to, go to Settings => Connection strings and set two connection strings with the same names and values you set in your App.config and set their type to "<em>Custom</em>". Once you do that, it will get picked up by convention and you'll be able to view the dashboard.  </p>

<p><img src="http://www.nibrasmanna.com/content/images/2016/07/appSettings.png" alt="Azure WebJobs"></p>

<p><strong>Tip</strong>: for simplicity, I like to use the same Storage Account for both Storage and Dashboard. I found it simple to have a single connection string in my App.config called "<em>Azure Storage</em>" and use that when initializing the WebJob.
<add name="AzureStorage" connectionstring=""></add></p>

<pre><code>var storageConnection = ConfigurationManager.ConnectionStrings["AzureStorage"].ConnectionString;  
var config = new JobHostConfiguration(storageConnection);  

var host = new JobHost(config);  
host.Start();  
</code></pre>

<p>This way, there is one less connection string to worry about and transform.</p>

<h4 id="logsretention">Logs Retention</h4>

<p>You can control the history size and retention for <strong>triggered</strong> WebJobs by using the <code>WEBJOBS_HISTORY_SIZE</code> setting (default is 50 invocations). Unfortunately, there isn't a way to control the history size for <strong>continuous</strong> WebJobs yet. <a href="https://github.com/Azure/azure-webjobs-sdk/issues/752">I've opened an issue</a> on the WebJob's GitHub repository for that which will hopefully be included in a future release. </p>

<h2 id="tipstricks">Tips &amp; Tricks</h2>

<ul>
<li>In the WebJob project under Properties, a <strong><a href="https://azure.microsoft.com/en-us/documentation/articles/websites-dotnet-deploy-webjobs/#publishsettings">webjob-publish-settings.json</a></strong> file is created which holds the configuration details such as the run mode and schedule. You can edit the schedule there or delete the file entirely to get the scheduling dialog in Visual Studio again.</li>
<li>For continuous WebJobs, the <strong>Always On</strong> setting needs to be turned on in the WebApp's settings to prevent the WebApp from getting unloaded when idle.</li>
<li>You can adjust the timeout value that the WebJobs SDK uses to kill idle function invocations (no CPU or IO activity). You can do that by adding an application setting <code>WEBJOBS_IDLE_TIMEOUT</code> with a value in seconds in the WebApp's application settings. This setting can be set programmatically as well. </li>
<li>If you want to take a look at the binaries deployed to the Azure WebApp, connect to the WebApp via FTP using a client such as <a href="https://filezilla-project.org/">FileZilla</a>, jobs will be under the following directory: <em>site/wwwroot/app_data/jobs</em></li>
<li>Enable Development Settings when running locally. This will adjust logging verbosity and other settings in order to optimize for local development. You can do that by:</li>
</ul>

<pre><code>if (config.IsDevelopment)  
{
    config.UseDevelopmentSettings();
}
</code></pre>

<p><strong>Note</strong>: you'll need to add an environment variable to your machine with a name "<em>AzureWebJobsEnv</em>" and a value of "<em>Development</em>"  </p>

<h2 id="webjobsappserviceautoscale">WebJobs &amp; AppService AutoScale</h2>

<p>Azure <a href="https://azure.microsoft.com/en-us/services/app-service/">AppService</a> (the underlying infrastructure that hosts the WebJob) can AutoScale to handle increasing load automatically <a href="https://azure.microsoft.com/en-us/documentation/articles/web-sites-scale/">(see here for more info)</a>. This will result in having multiple instances of you WebJob running. If you want to prevent your WebJob from AutoScaling, include a <em>settings.job</em> file with the following attributes:</p>

<pre><code>{
  "is_singleton" : true
}
</code></pre>

<p><strong>Note</strong>: make sure you right click on the file, go to properties, and change the "<em>Copy to Output Directory</em>" setting  to "<em>Copy Always</em>" so this file gets included when the WebJob gets deployed.</p>

<h2 id="restapi">REST API</h2>

<p>You can interact with your WebJobs through a <a href="https://github.com/projectkudu/kudu/wiki/WebJobs-API">REST API</a>. This comes handy when you want to start/stop or adjust the settings of your WebJobs programmatically. A good example of this is a SQL database maintenance WebJob we have that runs weekly to rebuild indexes and update statistics. That WebJob uses this API to stop all WebJobs that write to that database, performs its database maintenance work, then starts the jobs back up.  </p>

<p><strong>Note</strong>: you'll need to authenticate with the REST API via basic authentication. The username and password are found in the publish profile of the WebApp. </p>

<h2 id="additionalresources">Additional Resources</h2>

<p><a href="https://azure.microsoft.com/en-us/documentation/articles/web-sites-create-web-jobs/">Azure documentation</a> <br>
<a href="http://www.hanselman.com/blog/IntroducingWindowsAzureWebJobs.aspx">Introducing Windows Azure WebJobs</a> - Scott Hansleman's blog post <br>
<a href="https://app.pluralsight.com/library/courses/windows-azure-websites-web-jobs/table-of-contents">Azure Websites and WebJobs</a> - Pluralsight course <br>
<a href="https://github.com/Azure/azure-webjobs-sdk-samples">Sample projects</a>  </p>]]></content:encoded></item></channel></rss>