Skip to content

Instantly share code, notes, and snippets.

@pacodelacruz
pacodelacruz / WebJobWebTestFinal.xml
Last active August 11, 2016 11:39
Azure App Insights Web Test for Web Job Health Monitoring
<WebTest Name="My Web Job Health Monitor" Id="aaa239ee-097b-46cd-8890-2ae7a05edbbb" Enabled="True" CssProjectStructure="" CssIteration="" Timeout="120" WorkItemIds="" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" Description="" CredentialUserName="" CredentialPassword="" PreAuthenticate="True" Proxy="default" StopOnError="False" RecordedResultFile="" ResultsLocale="">
<Items>
<Request Method="GET" Guid="aaa5ae9c-35c3-c677-a930-27c90877dbbb" Version="1.1" Url="https://pacodelacruz-webapp.scm.azurewebsites.net/api/triggeredwebjobs/mywebjob/" ThinkTime="0" Timeout="120" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="200" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False">
<Headers>
<Header Name="Authorization" Value="Basic BAs3643nc0D3dS3Cr3T0k3n0123456789BAs3643nc0D3dS3Cr3T0k3n0123456789BAs3643nc0D3dS3Cr3T0k3nBAs3643nc0D3dS3" />
</Headers>
</Request>
</Items>
function Upload-FileToWebApp($resourceGroupName, $webAppName, $slotName = "", $localPath, $kuduPath){
$kuduApiAuthorisationToken = Get-KuduApiAuthorisationHeaderValue $resourceGroupName $webAppName $slotName
if ($slotName -eq ""){
$kuduApiUrl = "https://$webAppName.scm.azurewebsites.net/api/vfs/site/wwwroot/$kuduPath"
}
else{
$kuduApiUrl = "https://$webAppName`-$slotName.scm.azurewebsites.net/api/vfs/site/wwwroot/$kuduPath"
}
$virtualPath = $kuduApiUrl.Replace(".scm.azurewebsites.", ".azurewebsites.").Replace("/api/vfs/site/wwwroot", "")
function Download-FileFromWebApp($resourceGroupName, $webAppName, $slotName = "", $kuduPath, $localPath){
$kuduApiAuthorisationToken = Get-KuduApiAuthorisationHeaderValue $resourceGroupName $webAppName $slotName
if ($slotName -eq ""){
$kuduApiUrl = "https://$webAppName.scm.azurewebsites.net/api/vfs/site/wwwroot/$kuduPath"
}
else{
$kuduApiUrl = "https://$webAppName`-$slotName.scm.azurewebsites.net/api/vfs/site/wwwroot/$kuduPath"
}
$virtualPath = $kuduApiUrl.Replace(".scm.azurewebsites.", ".azurewebsites.").Replace("/api/vfs/site/wwwroot", "")
{
"id": "9ac0d31ac1234567890d685e57164f08",
"functionTimeout": "00:05:00",
"http": {
"routePrefix": "api"
},
"watchDirectories": [ "Shared" ],
"tracing": {
"consoleLevel": "info",
"fileLoggingMode": "debugOnly"
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=pacopollingconsumerstrg;AccountKey=[key];EndpointSuffix=core.windows.net",
"AzureWebJobsDashboard": "DefaultEndpointsProtocol=https;AccountName=pacopollingconsumerstrg;AccountKey=[key];EndpointSuffix=core.windows.net",
"PollingWatermarkStorage": "DefaultEndpointsProtocol=https;AccountName=pacopollingconsumerstrg;AccountKey=[key];EndpointSuffix=core.windows.net"
}
}
using System;
using Microsoft.WindowsAzure.Storage.Table;
namespace PacodelaCruz.PollingConsumer.FunctionApp
{
/// <summary>
/// Class to handle the entities on the Azure Table Storage called ‘PollingWatermark'.
/// If you want to learn more about using Azure Storage Tables with C# have a look at this documentation
/// https://docs.microsoft.com/en-us/azure/storage/storage-dotnet-how-to-use-tables
/// </summary>
using System;
namespace PacodelaCruz.PollingConsumer.FunctionApp
{
/// <summary>
/// This class will help us to wrap the PollingWatermarkEntity and make it more user friendly. By using the constructor, we are naming the PartitionKey as SourceSystem, and the RowKey as Entity. Additionally, we are returning another property called NextWatermark that is to be used as the upper bound when querying the source system and when updating the Polling Watermark after we have successfully polled the source system
/// </summary>
public class PollingWatermark
{
public string SourceSystem { get; set; }
{
"disabled": false,
"scriptFile": "..\\bin\\PacodelaCruz.PollingConsumer.FunctionApp.dll",
"entryPoint": "PacodelaCruz.PollingConsumer.FunctionApp.GetPollingWatermark.Run",
"bindings": [
{
"name": "req",
"type": "httpTrigger",
"direction": "in",
"methods": [ "get" ],
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Azure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Azure;