Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Upgrade to WindowsAzure.Storage 2.0.3.0

  • Loading branch information...
commit ffefb1344697ad382ff402207bd47db93645bd34 1 parent 249a3d2
@tathamoddie authored
View
13 IntegrationTests/Azure.cs
@@ -1,8 +1,11 @@
using System;
using Microsoft.WindowsAzure;
-using Microsoft.WindowsAzure.StorageClient;
+using Microsoft.WindowsAzure.Storage;
+using Microsoft.WindowsAzure.Storage.Blob;
using NUnit.Framework;
using SnowMaker;
+using System.Text;
+using System.IO;
namespace IntegrationTests.cs
{
@@ -40,8 +43,12 @@ public TestScope(CloudStorageAccount account)
public string ReadCurrentPersistedValue()
{
var blobContainer = blobClient.GetContainerReference(ContainerName);
- var blob = blobContainer.GetBlobReference(IdScopeName);
- return blob.DownloadText();
+ var blob = blobContainer.GetBlockBlobReference(IdScopeName);
+ using (var stream = new MemoryStream())
+ {
+ blob.DownloadToStream(stream);
+ return Encoding.UTF8.GetString(stream.ToArray());
+ }
}
public void Dispose()
View
20 IntegrationTests/IntegrationTests.csproj
@@ -33,7 +33,20 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Microsoft.WindowsAzure.StorageClient, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
+ <Reference Include="Microsoft.Data.Edm, Version=5.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\Microsoft.Data.Edm.5.0.2\lib\net40\Microsoft.Data.Edm.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.Data.OData, Version=5.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\Microsoft.Data.OData.5.0.2\lib\net40\Microsoft.Data.OData.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.WindowsAzure.Configuration">
+ <HintPath>..\packages\Microsoft.WindowsAzure.ConfigurationManager.1.8.0.0\lib\net35-full\Microsoft.WindowsAzure.Configuration.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.WindowsAzure.Storage">
+ <HintPath>..\packages\WindowsAzure.Storage.2.0.3.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
+ </Reference>
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
</Reference>
@@ -45,6 +58,11 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
+ <Reference Include="System.Data.Services.Client" />
+ <Reference Include="System.Spatial, Version=5.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\System.Spatial.5.0.2\lib\net40\System.Spatial.dll</HintPath>
+ </Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
View
5 IntegrationTests/packages.config
@@ -1,4 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
+ <package id="Microsoft.Data.Edm" version="5.0.2" targetFramework="net40" />
+ <package id="Microsoft.Data.OData" version="5.0.2" targetFramework="net40" />
+ <package id="Microsoft.WindowsAzure.ConfigurationManager" version="1.8.0.0" targetFramework="net40" />
<package id="NUnit" version="2.5.10.11092" />
+ <package id="System.Spatial" version="5.0.2" targetFramework="net40" />
+ <package id="WindowsAzure.Storage" version="2.0.3.0" targetFramework="net40" />
</packages>
View
64 SnowMaker/BlobOptimisticDataStore.cs
@@ -2,7 +2,9 @@
using System.Net;
using System.Text;
using Microsoft.WindowsAzure;
-using Microsoft.WindowsAzure.StorageClient;
+using Microsoft.WindowsAzure.Storage;
+using Microsoft.WindowsAzure.Storage.Blob;
+using System.IO;
namespace SnowMaker
{
@@ -12,22 +14,26 @@ public class BlobOptimisticDataStore : IOptimisticDataStore
readonly CloudBlobContainer blobContainer;
- readonly IDictionary<string, CloudBlob> blobReferences;
+ readonly IDictionary<string, ICloudBlob> blobReferences;
readonly object blobReferencesLock = new object();
public BlobOptimisticDataStore(CloudStorageAccount account, string containerName)
{
var blobClient = account.CreateCloudBlobClient();
blobContainer = blobClient.GetContainerReference(containerName.ToLower());
- blobContainer.CreateIfNotExist();
+ blobContainer.CreateIfNotExists();
- blobReferences = new Dictionary<string, CloudBlob>();
+ blobReferences = new Dictionary<string, ICloudBlob>();
}
public string GetData(string blockName)
{
var blobReference = GetBlobReference(blockName);
- return blobReference.DownloadText();
+ using (var stream = new MemoryStream())
+ {
+ blobReference.DownloadToStream(stream);
+ return Encoding.UTF8.GetString(stream.ToArray());
+ }
}
public bool TryOptimisticWrite(string scopeName, string data)
@@ -35,14 +41,14 @@ public bool TryOptimisticWrite(string scopeName, string data)
var blobReference = GetBlobReference(scopeName);
try
{
- blobReference.UploadText(
+ UploadText(
+ blobReference,
data,
- Encoding.Default,
- new BlobRequestOptions { AccessCondition = AccessCondition.IfMatch(blobReference.Properties.ETag) });
+ AccessCondition.GenerateIfMatchCondition(blobReference.Properties.ETag));
}
- catch (StorageClientException exc)
+ catch (StorageException exc)
{
- if (exc.StatusCode == HttpStatusCode.PreconditionFailed)
+ if (exc.RequestInformation.HttpStatusCode == (int)HttpStatusCode.PreconditionFailed)
return false;
throw;
@@ -50,7 +56,7 @@ public bool TryOptimisticWrite(string scopeName, string data)
return true;
}
- CloudBlob GetBlobReference(string blockName)
+ ICloudBlob GetBlobReference(string blockName)
{
return blobReferences.GetValue(
blockName,
@@ -58,34 +64,34 @@ CloudBlob GetBlobReference(string blockName)
() => InitializeBlobReference(blockName));
}
- private CloudBlob InitializeBlobReference(string blockName)
+ private ICloudBlob InitializeBlobReference(string blockName)
{
- var blobReference = blobContainer.GetBlobReference(blockName);
+ var blobReference = blobContainer.GetBlockBlobReference(blockName);
+
+ if (blobReference.Exists())
+ return blobReference;
try
{
- blobReference.DownloadText();
+ UploadText(blobReference, SeedValue, AccessCondition.GenerateIfNoneMatchCondition("*"));
}
- catch (StorageClientException downloadException)
+ catch (StorageException uploadException)
{
- if (downloadException.StatusCode != HttpStatusCode.NotFound)
+ if (uploadException.RequestInformation.HttpStatusCode != (int)HttpStatusCode.Conflict)
throw;
-
- try
- {
- blobReference.UploadText(
- SeedValue,
- Encoding.Default,
- new BlobRequestOptions { AccessCondition = AccessCondition.IfNoneMatch("*") });
- }
- catch (StorageClientException uploadException)
- {
- if (uploadException.StatusCode != HttpStatusCode.Conflict)
- throw;
- }
}
return blobReference;
}
+
+ void UploadText(ICloudBlob blob, string text, AccessCondition accessCondition)
+ {
+ blob.Properties.ContentEncoding = "UTF-8";
+ blob.Properties.ContentType = "text/plain";
+ using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(text)))
+ {
+ blob.UploadFromStream(stream, accessCondition);
+ }
+ }
}
}
View
24 SnowMaker/SnowMaker.csproj
@@ -12,6 +12,8 @@
<AssemblyName>SnowMaker</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+ <RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -31,9 +33,27 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Microsoft.WindowsAzure.StorageClient, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
+ <Reference Include="Microsoft.Data.Edm, Version=5.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\Microsoft.Data.Edm.5.0.2\lib\net40\Microsoft.Data.Edm.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.Data.OData, Version=5.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\Microsoft.Data.OData.5.0.2\lib\net40\Microsoft.Data.OData.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.WindowsAzure.Configuration">
+ <HintPath>..\packages\Microsoft.WindowsAzure.ConfigurationManager.1.8.0.0\lib\net35-full\Microsoft.WindowsAzure.Configuration.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.WindowsAzure.Storage">
+ <HintPath>..\packages\WindowsAzure.Storage.2.0.3.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
+ <Reference Include="System.Data.Services.Client" />
+ <Reference Include="System.Spatial, Version=5.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\System.Spatial.5.0.2\lib\net40\System.Spatial.dll</HintPath>
+ </Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@@ -58,9 +78,11 @@
</Compile>
</ItemGroup>
<ItemGroup>
+ <None Include="packages.config" />
<None Include="SnowMaker.nuspec" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
View
20 UnitTests/UnitTests.csproj
@@ -33,7 +33,20 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Microsoft.WindowsAzure.StorageClient, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
+ <Reference Include="Microsoft.Data.Edm, Version=5.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\Microsoft.Data.Edm.5.0.2\lib\net40\Microsoft.Data.Edm.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.Data.OData, Version=5.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\Microsoft.Data.OData.5.0.2\lib\net40\Microsoft.Data.OData.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.WindowsAzure.Configuration">
+ <HintPath>..\packages\Microsoft.WindowsAzure.ConfigurationManager.1.8.0.0\lib\net35-full\Microsoft.WindowsAzure.Configuration.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.WindowsAzure.Storage">
+ <HintPath>..\packages\WindowsAzure.Storage.2.0.3.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
+ </Reference>
<Reference Include="NSubstitute">
<HintPath>..\packages\NSubstitute.1.1.0.0\lib\35\NSubstitute.dll</HintPath>
</Reference>
@@ -48,6 +61,11 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
+ <Reference Include="System.Data.Services.Client" />
+ <Reference Include="System.Spatial, Version=5.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\System.Spatial.5.0.2\lib\net40\System.Spatial.dll</HintPath>
+ </Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
View
7 UnitTests/packages.config
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="NUnit" version="2.5.10.11092" />
+ <package id="Microsoft.Data.Edm" version="5.0.2" targetFramework="net40" />
+ <package id="Microsoft.Data.OData" version="5.0.2" targetFramework="net40" />
+ <package id="Microsoft.WindowsAzure.ConfigurationManager" version="1.8.0.0" targetFramework="net40" />
<package id="NSubstitute" version="1.1.0.0" />
+ <package id="NUnit" version="2.5.10.11092" />
+ <package id="System.Spatial" version="5.0.2" targetFramework="net40" />
+ <package id="WindowsAzure.Storage" version="2.0.3.0" targetFramework="net40" />
</packages>
View
1  packages/repositories.config
@@ -2,5 +2,6 @@
<repositories>
<repository path="..\IntegrationTests.cs\packages.config" />
<repository path="..\IntegrationTests\packages.config" />
+ <repository path="..\SnowMaker\packages.config" />
<repository path="..\UnitTests\packages.config" />
</repositories>
Please sign in to comment.
Something went wrong with that request. Please try again.