Click here to Skip to main content
15,886,799 members
Articles / Hosted Services / Azure

Using Azure Lease Blob

Rate me:
Please Sign up or sign in to vote.
5.00/5 (6 votes)
9 Jun 2013CPOL25 min read 38.1K   121   5  
This article describes how the Azure Lease Blob can help the composition of the business model during the runtime in the distributed event-driven pub/sub architecture.
<Activity mc:Ignorable="sads sap" x:Class="Test" sap:VirtualizedContainerService.HintSize="1107,1984" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:mvc="clr-namespace:Microsoft.VisualBasic.CompilerServices;assembly=Microsoft.VisualBasic" xmlns:mws="clr-namespace:Microsoft.WindowsAzure.Storage;assembly=Microsoft.WindowsAzure.Storage" xmlns:mwsb="clr-namespace:Microsoft.WindowsAzure.Storage.Blob;assembly=Microsoft.WindowsAzure.Storage" xmlns:raa="clr-namespace:RKiss.AzureLeaseBlob.ActivityLibrary;assembly=AzureLeaseBlob.ActivityLibrary" xmlns:raaa="clr-namespace:RKiss.AzureLeaseBlob.ActivityLibrary.Activities;assembly=AzureLeaseBlob.ActivityLibrary" xmlns:s="clr-namespace:System;assembly=System" xmlns:s1="clr-namespace:System;assembly=mscorlib" xmlns:s2="clr-namespace:System;assembly=System.Core" xmlns:s3="clr-namespace:System;assembly=System.ServiceModel" xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities" xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sco="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib" xmlns:sd="clr-namespace:System.Diagnostics;assembly=mscorlib" xmlns:sd1="clr-namespace:System.Diagnostics;assembly=System" xmlns:sd2="clr-namespace:System.Diagnostics;assembly=System.Core" xmlns:sd3="clr-namespace:System.Diagnostics;assembly=WindowsBase" xmlns:st="clr-namespace:System.Threading;assembly=mscorlib" xmlns:st1="clr-namespace:System.Threading;assembly=System" xmlns:st2="clr-namespace:System.Threading;assembly=System.Core" xmlns:sx="clr-namespace:System.Xml;assembly=System.Xml" xmlns:sx1="clr-namespace:System.Xml;assembly=System.Runtime.Serialization" xmlns:sx2="clr-namespace:System.Xml;assembly=System.Data" xmlns:sxl="clr-namespace:System.Xml.Linq;assembly=System.Xml.Linq" xmlns:sxs="clr-namespace:System.Xml.Serialization;assembly=System.Xml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"><Sequence sap:VirtualizedContainerService.HintSize="1067,1944" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces"><Sequence.Variables><Variable x:TypeArguments="mwsb:CloudBlockBlob" Name="blob" /><Variable x:TypeArguments="x:String" Default="DefaultEndpointsProtocol=https;AccountName=YOUR_ACCOUNT_NAME;AccountKey=YOUR_ACCOUNT_KEY" Name="applicationStorageAccount" /><Variable x:TypeArguments="x:String" Default="temp/eventstream2" Name="EventStreamRef" /><Variable x:TypeArguments="x:String" Name="leaseID" /><Variable x:TypeArguments="raa:EventStreamProcess" Name="esp" /><Variable x:TypeArguments="x:String" Default="00" Name="id" /><Variable x:TypeArguments="sxl:XElement" Name="curEvent" /><Variable x:TypeArguments="x:String" Default="10" Name="maxEvents" /><Variable x:TypeArguments="x:String" Default="[&quot;Process:&quot; + Process.GetCurrentProcess.Id.ToString]" Name="workerID" /></Sequence.Variables><sap:WorkflowViewStateService.ViewState><scg:Dictionary x:TypeArguments="x:String, x:Object"><x:Boolean x:Key="IsExpanded">True</x:Boolean></scg:Dictionary></sap:WorkflowViewStateService.ViewState><WriteLine sap:VirtualizedContainerService.HintSize="1045,60" Text="Start ..." /><Assign DisplayName="Assign Blob" sap:VirtualizedContainerService.HintSize="1045,60"><Assign.To><OutArgument x:TypeArguments="mwsb:CloudBlockBlob">[blob]</OutArgument></Assign.To><Assign.Value><InArgument x:TypeArguments="mwsb:CloudBlockBlob">[CloudBlockBlobExtensions.BlobClient(applicationStorageAccount).GetBlockBlobReference(EventStreamRef)]</InArgument></Assign.Value></Assign><If Condition="[blob.Exists]" DisplayName="IfBlobExists" sap:VirtualizedContainerService.HintSize="1045,1520"><If.Then><DoWhile DisplayName="DoWhile " sap:VirtualizedContainerService.HintSize="534,1416"><sap:WorkflowViewStateService.ViewState><scg:Dictionary x:TypeArguments="x:String, x:Object"><x:Boolean x:Key="IsExpanded">True</x:Boolean><x:Boolean x:Key="IsPinned">False</x:Boolean></scg:Dictionary></sap:WorkflowViewStateService.ViewState><DoWhile.Condition>[esp.IsDone = false]</DoWhile.Condition><Sequence DisplayName="Sequence Loop" sap:VirtualizedContainerService.HintSize="508,1298"><Sequence.Variables><Variable x:TypeArguments="x:TimeSpan" Name="delay" /></Sequence.Variables><sap:WorkflowViewStateService.ViewState><scg:Dictionary x:TypeArguments="x:String, x:Object"><x:Boolean x:Key="IsExpanded">True</x:Boolean></scg:Dictionary></sap:WorkflowViewStateService.ViewState><raaa:LeaseBlobScope BlobAddress="[EventStreamRef]" ConfigurationName="[applicationStorageAccount]" sap:VirtualizedContainerService.HintSize="486,712" LeaseId="[leaseID]" LeaseTime="00:00:50" Result="[blob]"><sap:WorkflowViewStateService.ViewState><scg:Dictionary x:TypeArguments="x:String, x:Object"><x:Boolean x:Key="IsExpanded">True</x:Boolean><x:Boolean x:Key="IsPinned">False</x:Boolean></scg:Dictionary></sap:WorkflowViewStateService.ViewState><Assign DisplayName="Assign LoadEventStream" sap:VirtualizedContainerService.HintSize="464,60"><Assign.To><OutArgument x:TypeArguments="raa:EventStreamProcess">[esp]</OutArgument></Assign.To><Assign.Value><InArgument x:TypeArguments="raa:EventStreamProcess">[new EventStreamProcess(blob.ToXml(leaseId))]</InArgument></Assign.Value></Assign><Assign DisplayName="Assign curEvent" sap:VirtualizedContainerService.HintSize="464,60"><Assign.To><OutArgument x:TypeArguments="sxl:XElement">[curEvent]</OutArgument></Assign.To><Assign.Value><InArgument x:TypeArguments="sxl:XElement">[esp.Select("./Event[@status='init']")]</InArgument></Assign.Value></Assign><If Condition="[curEvent isnot nothing]" DisplayName="If curEvent" sap:VirtualizedContainerService.HintSize="464,388"><sap:WorkflowViewStateService.ViewState><scg:Dictionary x:TypeArguments="x:String, x:Object"><x:Boolean x:Key="IsExpanded">True</x:Boolean><x:Boolean x:Key="IsPinned">False</x:Boolean></scg:Dictionary></sap:WorkflowViewStateService.ViewState><If.Then><Sequence DisplayName="Sequence Update" sap:VirtualizedContainerService.HintSize="262,284"><sap:WorkflowViewStateService.ViewState><scg:Dictionary x:TypeArguments="x:String, x:Object"><x:Boolean x:Key="IsExpanded">True</x:Boolean></scg:Dictionary></sap:WorkflowViewStateService.ViewState><Assign DisplayName="Assign Update" sap:VirtualizedContainerService.HintSize="240,60"><Assign.To><OutArgument x:TypeArguments="raa:EventStreamProcess">[esp]</OutArgument></Assign.To><Assign.Value><InArgument x:TypeArguments="raa:EventStreamProcess" xml:space="preserve">[esp.Update(curEvent, "key", workerID).
Update(curEvent, "status", "completed")]</InArgument></Assign.Value></Assign><Assign DisplayName="Assign SaveEventStream" sap:VirtualizedContainerService.HintSize="240,60"><Assign.To><OutArgument x:TypeArguments="sxl:XElement">[esp.EventStream]</OutArgument></Assign.To><Assign.Value><InArgument x:TypeArguments="sxl:XElement">[blob.FromXml(esp.EventStream, leaseId)]</InArgument></Assign.Value></Assign></Sequence></If.Then></If></raaa:LeaseBlobScope><WriteLine sap:VirtualizedContainerService.HintSize="486,60"><InArgument x:TypeArguments="x:String"><Literal x:TypeArguments="x:String" Value="" /></InArgument></WriteLine><WriteLine sap:VirtualizedContainerService.HintSize="486,60" Text="[esp.EventStream.ToString]" /><Assign DisplayName="Assign Delay" sap:VirtualizedContainerService.HintSize="486,60"><Assign.To><OutArgument x:TypeArguments="x:TimeSpan">[delay]</OutArgument></Assign.To><Assign.Value><InArgument x:TypeArguments="x:TimeSpan">[TimeSpan.FromMilliseconds(new Random(Guid.NewGuid().GetHashCode()).Next(1500, 4500))]</InArgument></Assign.Value></Assign><WriteLine sap:VirtualizedContainerService.HintSize="486,60" Text="[&quot;Wait for &quot; + delay.ToString]" /><Delay DisplayName="Random Delay" Duration="[delay]" sap:VirtualizedContainerService.HintSize="486,22" /></Sequence></DoWhile></If.Then><If.Else><Sequence DisplayName="Sequence Init" sap:VirtualizedContainerService.HintSize="486,826"><sap:WorkflowViewStateService.ViewState><scg:Dictionary x:TypeArguments="x:String, x:Object"><x:Boolean x:Key="IsExpanded">True</x:Boolean></scg:Dictionary></sap:WorkflowViewStateService.ViewState><Assign DisplayName="Assign CreateESP" sap:VirtualizedContainerService.HintSize="464,60"><Assign.To><OutArgument x:TypeArguments="raa:EventStreamProcess">[esp]</OutArgument></Assign.To><Assign.Value><InArgument x:TypeArguments="raa:EventStreamProcess" xml:space="preserve">[EventStreamProcess.Create("EventStreamSearch", Guid.NewGuid.ToString, "Dev", "Test").
Add(new EventP with {
 .name="Order",
 .status="inprocess",
 .id=id,
  .key="",
 .topic="Search",
 .tag="",
 .trackingId="Process:" + Process.GetCurrentProcess.Id.ToString,
 .created=DateTime.UtcNow.ToString,
 .timestamp="",
 .timeout="0"
})]</InArgument></Assign.Value></Assign><DoWhile sap:VirtualizedContainerService.HintSize="464,402" Condition="[id &lt;&gt;  maxEvents]"><Sequence DisplayName="Sequence AddEvent" sap:VirtualizedContainerService.HintSize="262,284"><sap:WorkflowViewStateService.ViewState><scg:Dictionary x:TypeArguments="x:String, x:Object"><x:Boolean x:Key="IsExpanded">True</x:Boolean></scg:Dictionary></sap:WorkflowViewStateService.ViewState><Assign DisplayName="Assign id" sap:VirtualizedContainerService.HintSize="240,60"><Assign.To><OutArgument x:TypeArguments="x:String">[id]</OutArgument></Assign.To><Assign.Value><InArgument x:TypeArguments="x:String">[id.Increment]</InArgument></Assign.Value></Assign><Assign DisplayName="Assign Add" sap:VirtualizedContainerService.HintSize="240,60"><Assign.To><OutArgument x:TypeArguments="raa:EventStreamProcess">[esp]</OutArgument></Assign.To><Assign.Value><InArgument x:TypeArguments="raa:EventStreamProcess" xml:space="preserve">[esp.AddAndLink(new EventP with {
 .name="Search",
 .status="init",
 .id=id,
 .key="",
 .topic="Search",
 .created=DateTime.UtcNow.ToString,
 .timeout="60"}, "00")]</InArgument></Assign.Value></Assign></Sequence></DoWhile><Assign DisplayName="Assign SaveEventStream" sap:VirtualizedContainerService.HintSize="464,60"><Assign.To><OutArgument x:TypeArguments="sxl:XElement">[esp.EventStream]</OutArgument></Assign.To><Assign.Value><InArgument x:TypeArguments="sxl:XElement">[blob.FromXml(esp.EventStream, nothing)]</InArgument></Assign.Value></Assign><WriteLine sap:VirtualizedContainerService.HintSize="464,60" Text="[esp.EventStream.ToString]" /></Sequence></If.Else></If><WriteLine sap:VirtualizedContainerService.HintSize="1045,60" Text="--- Done ---" /></Sequence></Activity>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions