Skip to content

Commit 5a0de72

Browse files
committed
updated with some additional workflows
1 parent 2c6566f commit 5a0de72

File tree

105 files changed

+33715
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+33715
-17
lines changed

Elastacloud.FluentExamples.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{F408B8
1010
.nuget\NuGet.targets = .nuget\NuGet.targets
1111
EndProjectSection
1212
EndProject
13+
Project("{CC5FD16D-436D-48AD-A40C-5A424C6E3E79}") = "TestCloudInstall", "TestCloudInstall\TestCloudInstall.ccproj", "{96ADE123-26D8-4308-AAB7-B3DD0CE08031}"
14+
EndProject
15+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExampleWebRole", "ExampleWebRole\ExampleWebRole.csproj", "{0FD09EB7-FBB3-481D-AF09-B9BD1251C75C}"
16+
EndProject
1317
Global
1418
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1519
Debug|Any CPU = Debug|Any CPU
@@ -20,6 +24,14 @@ Global
2024
{2ACCFE36-B097-4658-90C0-79498BFF6EEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
2125
{2ACCFE36-B097-4658-90C0-79498BFF6EEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
2226
{2ACCFE36-B097-4658-90C0-79498BFF6EEA}.Release|Any CPU.Build.0 = Release|Any CPU
27+
{96ADE123-26D8-4308-AAB7-B3DD0CE08031}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28+
{96ADE123-26D8-4308-AAB7-B3DD0CE08031}.Debug|Any CPU.Build.0 = Debug|Any CPU
29+
{96ADE123-26D8-4308-AAB7-B3DD0CE08031}.Release|Any CPU.ActiveCfg = Release|Any CPU
30+
{96ADE123-26D8-4308-AAB7-B3DD0CE08031}.Release|Any CPU.Build.0 = Release|Any CPU
31+
{0FD09EB7-FBB3-481D-AF09-B9BD1251C75C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32+
{0FD09EB7-FBB3-481D-AF09-B9BD1251C75C}.Debug|Any CPU.Build.0 = Debug|Any CPU
33+
{0FD09EB7-FBB3-481D-AF09-B9BD1251C75C}.Release|Any CPU.ActiveCfg = Release|Any CPU
34+
{0FD09EB7-FBB3-481D-AF09-B9BD1251C75C}.Release|Any CPU.Build.0 = Release|Any CPU
2335
EndGlobalSection
2436
GlobalSection(SolutionProperties) = preSolution
2537
HideSolutionNode = FALSE

Elastacloud.FluentExamples/App.config

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3+
<appSettings>
4+
<add key="dbname" value="stacked"/>
5+
<add key="username" value="azurecoder"/>
6+
<add key="password" value="Password101!"/>
7+
<add key="sql_db_username" value="azurecoder_db"/>
8+
<add key="default_storage" value="stackedstorage"/>
9+
<add key="mobile_service_name" value="stackedmobile"/>
10+
<add key="deployment_name" value="stacked deployment"/>
11+
<add key="publishsettings" value="C:\Users\Richard\Desktop\Engagements\AllAccounts.publishsettings"/>
12+
<add key="rdpfile" value="C:\Users\Richard\Desktop\Engagements\stackedliverpool.rdp"/>
13+
<add key="vmroleservice" value="stackedliverpool"/>
14+
<add key="cloudservice" value="stackedliverpoolpaas"/>
15+
<add key="rolename" value="ExampleWebRole"/>
16+
</appSettings>
317
<startup>
418
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
519
</startup>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Net;
5+
using System.Security.Cryptography;
6+
using System.Security.Cryptography.X509Certificates;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
using Elastacloud.AzureManagement.Fluent.Clients;
10+
11+
namespace Elastacloud.FluentExamples
12+
{
13+
public class BuildGetBlobRequest : IWorkflow
14+
{
15+
private readonly string _subscriptionId;
16+
private readonly X509Certificate2 _managementCertificate;
17+
18+
public BuildGetBlobRequest(string subscriptionId, X509Certificate2 managementCertificate)
19+
{
20+
_subscriptionId = subscriptionId;
21+
_managementCertificate = managementCertificate;
22+
}
23+
24+
#region Implementation of IWorkflow
25+
26+
public void PreActionSteps()
27+
{
28+
// use AMS to transfer file
29+
var storageClient = new StorageClient(_subscriptionId, _managementCertificate);
30+
var keys = storageClient.GetStorageAccountKeys("stackedstorage");
31+
StorageKey = keys[0];
32+
}
33+
34+
public void PostActionSteps()
35+
{
36+
Console.WriteLine("no postbuild action steps");
37+
}
38+
39+
public void DoWork()
40+
{
41+
var date = DateTime.UtcNow.ToString("R");
42+
var lineEndings = new string('\n', 12);
43+
var builder = new StringBuilder("GET");
44+
builder.Append(lineEndings);
45+
builder.AppendFormat("x-ms-date:{0}\n", date);
46+
builder.AppendFormat("x-ms-version:2011-08-18\n");
47+
builder.Append("/stackedstorage/docs/test.txt\n");
48+
builder.Append("timeout:90");
49+
50+
string signature;
51+
using (var hmacSha256 = new HMACSHA256(Convert.FromBase64String(StorageKey)))
52+
{
53+
Byte[] bytes = Encoding.UTF8.GetBytes(builder.ToString());
54+
signature = Convert.ToBase64String(hmacSha256.ComputeHash(bytes));
55+
}
56+
57+
var authValue = "SharedKey stackedstorage:" + signature;
58+
59+
var request = (HttpWebRequest)WebRequest.Create("http://stackedstorage.blob.core.windows.net/docs/test.txt?timeout=90");
60+
request.Method = "GET";
61+
request.ContentLength = 0;
62+
request.Headers.Add("x-ms-date", date);
63+
request.Headers.Add("x-ms-version", "2011-08-18");
64+
request.Headers.Add("Authorization", authValue);
65+
request.GetResponse();
66+
67+
Console.WriteLine("Getting blob now!");
68+
}
69+
70+
#endregion
71+
72+
public string StorageKey { get; private set; }
73+
}
74+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Security.Cryptography.X509Certificates;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using Elastacloud.AzureManagement.Fluent.Clients;
8+
using Elastacloud.AzureManagement.Fluent.Types.MobileServices;
9+
10+
namespace Elastacloud.FluentExamples
11+
{
12+
public class BuildMobileService : IBuilder
13+
{
14+
public BuildMobileService(string subscriptionId, X509Certificate2 managementCertificate)
15+
{
16+
SubscriptionId = subscriptionId;
17+
ManagementCertificate = managementCertificate;
18+
}
19+
20+
#region Implementation of IBuilder
21+
22+
public void SpinUp()
23+
{
24+
var client = new MobileServiceClient(SubscriptionId, ManagementCertificate);
25+
client.CreateMobileServiceWithNewDb("mobilestacked", "azurecoder", "Password101!");
26+
Console.WriteLine("Yeah, we created a mobile service using the Service Management API - even though it hasn't been published yet!");
27+
28+
// Display some details about the mobile service
29+
Console.WriteLine("Application key: {0}", client.ApplicationKey);
30+
Console.WriteLine("Application url: {0}", client.ApplicationUrl);
31+
Console.WriteLine("Description: {0}", client.Description);
32+
Console.WriteLine("Location: {0}", client.Location);
33+
Console.WriteLine("Master key: {0}", client.MasterKey);
34+
Console.WriteLine("Mobile service Db name: {0}", client.MobileServiceDbName);
35+
Console.WriteLine("Mobile service server name: {0}", client.MobileServiceSqlName);
36+
Console.WriteLine("Sql Azure Db name: {0}", client.SqlAzureDbName);
37+
Console.WriteLine("Sql Azure server name: {0}", client.SqlAzureServerName);
38+
Console.WriteLine("Mobile service state: {0}", client.MobileServiceState.ToString());
39+
}
40+
41+
public void TearDown()
42+
{
43+
Console.WriteLine("Haven't implemented a teardown!");
44+
}
45+
46+
public void DoSomething()
47+
{
48+
var client = new MobileServiceClient(SubscriptionId, ManagementCertificate, "mobilestacked");
49+
if (!client.Tables.Exists(a => a.TableName == "Speakers"))
50+
client.AddTable("Speakers");
51+
client.AddTableScript(CrudOperation.Insert, "Speakers", "function insert(item, user, request){ /*Another fluent success!*/request.execute();}", Roles.User);
52+
client.FacebookClientId = "test";
53+
client.FacebookClientSecret = "test";
54+
client.GoogleClientId = "test";
55+
client.GoogleClientSecret = "test";
56+
client.TwitterClientId = "test";
57+
client.TwitterClientSecret = "test";
58+
client.DynamicSchemaEnabled = true;
59+
client.MicrosoftAccountClientId = "test";
60+
client.MicrosoftAccountClientSecret = "test";
61+
client.Update();
62+
63+
Console.WriteLine("Application key: {0}", client.ApplicationKey);
64+
Console.WriteLine("Application url: {0}", client.ApplicationUrl);
65+
Console.WriteLine("Description: {0}", client.Description);
66+
Console.WriteLine("Location: {0}", client.Location);
67+
Console.WriteLine("Master key: {0}", client.MasterKey);
68+
Console.WriteLine("Mobile service Db name: {0}", client.MobileServiceDbName);
69+
Console.WriteLine("Mobile service server name: {0}", client.MobileServiceSqlName);
70+
Console.WriteLine("Sql Azure Db name: {0}", client.SqlAzureDbName);
71+
Console.WriteLine("Sql Azure server name: {0}", client.SqlAzureServerName);
72+
Console.WriteLine("Mobile service state: {0}", client.MobileServiceState.ToString());
73+
foreach (var table in client.Tables)
74+
{
75+
Console.WriteLine("==================================================");
76+
Console.WriteLine("Table name: {0}", table.TableName);
77+
Console.WriteLine("Size: {0} bytes", table.SizeInBytes);
78+
Console.WriteLine("Row count: {0}", table.NumberOfRecords);
79+
Console.WriteLine("No of indexes: {0}", table.NumberOfIndexes);
80+
Console.WriteLine("Read permission: {0}", table.ReadPermission);
81+
Console.WriteLine("Insert permission: {0}", table.InsertPermission);
82+
Console.WriteLine("Delete permission: {0}", table.DeletePermission);
83+
Console.WriteLine("Update permission: {0}", table.UpdatePermission);
84+
Console.WriteLine("==================================================");
85+
}
86+
87+
var logs = client.Logs;
88+
Console.WriteLine("There are {0} log entries", logs.Count);
89+
Console.WriteLine("There are {0} error log entries", logs.Count(a => a.Type == LogLevelType.Error));
90+
Console.WriteLine("There are {0} warning log entries", logs.Count(a => a.Type == LogLevelType.Warning));
91+
Console.WriteLine("There are {0} information log entries", logs.Count(a => a.Type == LogLevelType.Information));
92+
client.RegenerateKeys();
93+
client.Restart();
94+
}
95+
96+
public string SubscriptionId { get; private set; }
97+
public X509Certificate2 ManagementCertificate { get; private set; }
98+
99+
#endregion
100+
}
101+
}

Elastacloud.FluentExamples/BuildVirtualMachine.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ void IBuilder.TearDown()
7979
Console.WriteLine("Virtual machine has been deleted, with cloud service and storage");
8080
}
8181

82+
public void DoSomething()
83+
{
84+
Console.WriteLine("Nothing to do!");
85+
}
86+
8287
X509Certificate2 IBuilder.ManagementCertificate
8388
{
8489
get { return _certificate; }

Elastacloud.FluentExamples/Elastacloud.FluentExamples.csproj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
</Reference>
4141
<Reference Include="Elastacloud.AzureManagement.Fluent, Version=0.4.4.0, Culture=neutral, processorArchitecture=MSIL">
4242
<SpecificVersion>False</SpecificVersion>
43-
<HintPath>..\packages\Elastacloud.AzureManagement.Fluent.0.4.4.8\lib\Elastacloud.AzureManagement.Fluent.dll</HintPath>
43+
<HintPath>..\..\..\Fluent Management\Elastacloud.AzureManagement.Fluent\bin\Debug\Elastacloud.AzureManagement.Fluent.dll</HintPath>
4444
</Reference>
4545
<Reference Include="Microsoft.SqlServer.ConnectionInfo, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
4646
<Private>True</Private>
@@ -73,10 +73,15 @@
7373
<Reference Include="System.Xml" />
7474
</ItemGroup>
7575
<ItemGroup>
76+
<Compile Include="BuildGetBlobRequest.cs" />
77+
<Compile Include="BuildMobileService.cs" />
7678
<Compile Include="BuildVirtualMachine.cs" />
79+
<Compile Include="WorkflowFluentDeploymentWithSSL.cs" />
80+
<Compile Include="WorkflowRoleSystemWatcher.cs" />
81+
<Compile Include="WorkflowFluentDeployment.cs" />
7782
<Compile Include="IBuilder.cs" />
7883
<Compile Include="IWorkflow.cs" />
79-
<Compile Include="LinqToStorage.cs" />
84+
<Compile Include="WorkflowLinqToStorage.cs" />
8085
<Compile Include="Program.cs" />
8186
<Compile Include="Properties\AssemblyInfo.cs" />
8287
</ItemGroup>

Elastacloud.FluentExamples/IBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ interface IBuilder
66
{
77
void SpinUp();
88
void TearDown();
9+
void DoSomething();
910
string SubscriptionId { get; }
1011
X509Certificate2 ManagementCertificate { get; }
1112
}

Elastacloud.FluentExamples/Program.cs

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,42 @@ class Program
1515
// args 2 - the path to the rdp output file
1616
static void Main(string[] args)
1717
{
18+
var builders = new List<IBuilder>();
19+
var workflows = new List<IWorkflow>();
1820
// create a virtual machine
1921
IBuilder virtualMachine = new BuildVirtualMachine(args[0], args[1], args[2]);
22+
builders.Add(virtualMachine);
2023

21-
// test linq to azure with storage
22-
IWorkflow linqToStorage = new LinqToStorage(virtualMachine.SubscriptionId, virtualMachine.ManagementCertificate);
23-
linqToStorage.PreActionSteps();
24-
linqToStorage.DoWork();
25-
linqToStorage.PostActionSteps();
26-
Debugger.Break();
24+
// Add the test get blob API - before running this create a storage account using AMS called stackedstorage
25+
IWorkflow getBlob = new BuildGetBlobRequest(virtualMachine.SubscriptionId, virtualMachine.ManagementCertificate);
26+
workflows.Add(getBlob);
2727

28-
// test linq to azure with cloud services
28+
// test linq to azure with storage
29+
IWorkflow linqToStorage = new WorkflowLinqToStorage(virtualMachine.SubscriptionId, virtualMachine.ManagementCertificate);
30+
workflows.Add(linqToStorage);
2931

30-
// test role system watcher
32+
// test create a mobile services deployment
33+
IBuilder mobileService = new BuildMobileService(virtualMachine.SubscriptionId, virtualMachine.ManagementCertificate);
34+
builders.Add(mobileService);
3135

3236
// test paas deployment
33-
37+
// test linq to azure with cloud services
3438
// test paas orchestration
39+
IWorkflow fluentDeployment = new WorkflowFluentDeployment(virtualMachine.SubscriptionId, virtualMachine.ManagementCertificate);
40+
workflows.Add(fluentDeployment);
41+
42+
// test role system watcher
43+
var watcher = new WorkflowRoleSystemWatcher(virtualMachine.SubscriptionId, virtualMachine.ManagementCertificate);
44+
workflows.Add(watcher);
45+
watcher.DoWork();
3546

36-
// test create a mobile services deployment
47+
// test paas build
3748

38-
// manipulate and transform config files
49+
3950

40-
// test virtual machine deployment
41-
virtualMachine.SpinUp();
42-
Debugger.Break();
43-
virtualMachine.TearDown();
4451

52+
53+
// manipulate and transform config files
4554
Console.WriteLine("Press [ENTER] to exit");
4655
Console.Read();
4756
}

0 commit comments

Comments
 (0)