Skip to content

Commit 5c33149

Browse files
authored
Merge pull request #5 from tamram/master
Adding additional samples for Blob storage
2 parents e3f2e24 + 1b717e2 commit 5c33149

File tree

9 files changed

+2233
-335
lines changed

9 files changed

+2233
-335
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ BlobStorage/bin/Debug/BlobStorage.exe
55
*.xml
66
BlobStorage/obj/Debug/*.*
77
BlobStorage/bin/Debug/*.*
8+
BlobStorage/StyleCop.cache
89
*.nupkg
9-
packages/Newtonsoft.Json.5.0.8/tools/install.ps1
10+
packages/*
1011
*.ps1
11-
packages/WindowsAzure.Storage.5.0.2/nuget.exe

BlobStorage.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.23107.0
4+
VisualStudioVersion = 14.0.24720.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlobStorage", "BlobStorage\BlobStorage.csproj", "{61EF4B90-9020-4C38-8FED-D248246BE9CA}"
77
EndProject

BlobStorage/Advanced.cs

Lines changed: 1770 additions & 0 deletions
Large diffs are not rendered by default.

BlobStorage/App.config

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<appSettings>
4-
<!-- By default we are assuming you will use the Azure SDK Storage Emulator. If you have an Azure Subscription you can alternatively
5-
create a Storage Account and run against the storage service by commenting out the connection string below and using the
6-
second connection string - in which case you must also insert your storage account name and key in the line below. -->
4+
<!-- This sample is configured for running against the storage emulator on Windows.
5+
If you have an Azure subscription and prefer to run the samples against Azure Storage, or if you are running on Linux or OS X,
6+
you can create a storage account and run against Azure Storage. Comment out the connection string below and use the
7+
second connection string. Insert your storage account name and key in the placeholders in the line below.
8+
We recommend creating a new storage account for testing purposes, rather than using a production account for running the samples.-->
79
<add key="StorageConnectionString" value="UseDevelopmentStorage=true;" />
810
<!--<add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=[AccountName];AccountKey=[AccountKey]" />-->
911
</appSettings>
12+
<runtime>
13+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
14+
<dependentAssembly>
15+
<assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />
16+
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
17+
</dependentAssembly>
18+
<dependentAssembly>
19+
<assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
20+
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
21+
</dependentAssembly>
22+
<dependentAssembly>
23+
<assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
24+
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
25+
</dependentAssembly>
26+
<dependentAssembly>
27+
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
28+
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
29+
</dependentAssembly>
30+
</assemblyBinding>
31+
</runtime>
1032
</configuration>

BlobStorage/BlobStorage.csproj

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,34 +37,34 @@
3737
<HintPath>..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll</HintPath>
3838
<Private>True</Private>
3939
</Reference>
40-
<Reference Include="Microsoft.Data.Edm, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
41-
<HintPath>..\packages\Microsoft.Data.Edm.5.6.4\lib\net40\Microsoft.Data.Edm.dll</HintPath>
40+
<Reference Include="Microsoft.Data.Edm, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
41+
<HintPath>..\packages\Microsoft.Data.Edm.5.7.0\lib\net40\Microsoft.Data.Edm.dll</HintPath>
4242
<Private>True</Private>
4343
</Reference>
44-
<Reference Include="Microsoft.Data.OData, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
45-
<HintPath>..\packages\Microsoft.Data.OData.5.6.4\lib\net40\Microsoft.Data.OData.dll</HintPath>
44+
<Reference Include="Microsoft.Data.OData, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
45+
<HintPath>..\packages\Microsoft.Data.OData.5.7.0\lib\net40\Microsoft.Data.OData.dll</HintPath>
4646
<Private>True</Private>
4747
</Reference>
48-
<Reference Include="Microsoft.Data.Services.Client, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
49-
<HintPath>..\packages\Microsoft.Data.Services.Client.5.6.4\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
48+
<Reference Include="Microsoft.Data.Services.Client, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
49+
<HintPath>..\packages\Microsoft.Data.Services.Client.5.7.0\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
5050
<Private>True</Private>
5151
</Reference>
52-
<Reference Include="Microsoft.WindowsAzure.Configuration, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
53-
<HintPath>..\packages\Microsoft.WindowsAzure.ConfigurationManager.1.8.0.0\lib\net35-full\Microsoft.WindowsAzure.Configuration.dll</HintPath>
52+
<Reference Include="Microsoft.WindowsAzure.Configuration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
53+
<HintPath>..\packages\Microsoft.WindowsAzure.ConfigurationManager.3.2.1\lib\net40\Microsoft.WindowsAzure.Configuration.dll</HintPath>
5454
<Private>True</Private>
5555
</Reference>
56-
<Reference Include="Microsoft.WindowsAzure.Storage, Version=6.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
57-
<HintPath>..\packages\WindowsAzure.Storage.6.2.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
56+
<Reference Include="Microsoft.WindowsAzure.Storage, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
57+
<HintPath>..\packages\WindowsAzure.Storage.7.0.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
5858
<Private>True</Private>
5959
</Reference>
60-
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
61-
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
60+
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
61+
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
6262
<Private>True</Private>
6363
</Reference>
6464
<Reference Include="System" />
6565
<Reference Include="System.Core" />
66-
<Reference Include="System.Spatial, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
67-
<HintPath>..\packages\System.Spatial.5.6.4\lib\net40\System.Spatial.dll</HintPath>
66+
<Reference Include="System.Spatial, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
67+
<HintPath>..\packages\System.Spatial.5.7.0\lib\net40\System.Spatial.dll</HintPath>
6868
<Private>True</Private>
6969
</Reference>
7070
<Reference Include="System.Xml.Linq" />
@@ -75,6 +75,9 @@
7575
<Reference Include="System.Xml" />
7676
</ItemGroup>
7777
<ItemGroup>
78+
<Compile Include="Advanced.cs" />
79+
<Compile Include="Common.cs" />
80+
<Compile Include="GettingStarted.cs" />
7881
<Compile Include="Program.cs" />
7982
<Compile Include="Properties\AssemblyInfo.cs" />
8083
</ItemGroup>

BlobStorage/Common.cs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//----------------------------------------------------------------------------------
2+
// Microsoft Developer & Platform Evangelism
3+
//
4+
// Copyright (c) Microsoft Corporation. All rights reserved.
5+
//
6+
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
7+
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
8+
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
9+
//----------------------------------------------------------------------------------
10+
// The example companies, organizations, products, domain names,
11+
// e-mail addresses, logos, people, places, and events depicted
12+
// herein are fictitious. No association with any real company,
13+
// organization, product, domain name, email address, logo, person,
14+
// places, or events is intended or should be inferred.
15+
//----------------------------------------------------------------------------------
16+
17+
18+
namespace BlobStorage
19+
{
20+
using System;
21+
using Microsoft.Azure;
22+
using Microsoft.WindowsAzure.Storage;
23+
24+
/// <summary>
25+
/// Contains public method for validating the storage connection string.
26+
/// </summary>
27+
public static class Common
28+
{
29+
/// <summary>
30+
/// Validates the connection string information in app.config and throws an exception if it looks like
31+
/// the user hasn't updated this to valid values.
32+
/// </summary>
33+
/// <returns>CloudStorageAccount object</returns>
34+
public static CloudStorageAccount CreateStorageAccountFromConnectionString()
35+
{
36+
CloudStorageAccount storageAccount;
37+
const string Message = "Invalid storage account information provided. Please confirm the AccountName and AccountKey are valid in the app.config file - then restart the sample.";
38+
39+
try
40+
{
41+
storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
42+
}
43+
catch (FormatException)
44+
{
45+
Console.WriteLine(Message);
46+
Console.ReadLine();
47+
throw;
48+
}
49+
catch (ArgumentException)
50+
{
51+
Console.WriteLine(Message);
52+
Console.ReadLine();
53+
throw;
54+
}
55+
56+
return storageAccount;
57+
}
58+
}
59+
}

0 commit comments

Comments
 (0)