Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ BlobStorage/StyleCop.cache
*.nupkg
packages/*
*.ps1
.vs/*
59 changes: 6 additions & 53 deletions BlobStorage/Advanced.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@

namespace BlobStorage
{
using Microsoft.Azure;
using Microsoft.Azure.Storage;
using Microsoft.Azure.Storage.Blob;
using Microsoft.Azure.Storage.RetryPolicies;
using Microsoft.Azure.Storage.Shared.Protocol;
using System;
using System.Collections.Generic;
using System.IO;
Expand All @@ -24,12 +29,6 @@ namespace BlobStorage
using System.ServiceModel.Channels;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Blob;
using Microsoft.WindowsAzure.Storage.RetryPolicies;
using Microsoft.WindowsAzure.Storage.Shared.Protocol;

/// <summary>
/// Advanced samples for Blob storage, including samples demonstrating a variety of client library classes and methods.
Expand Down Expand Up @@ -112,7 +111,6 @@ public static async Task CallBlobAdvancedSamples()
// The sample code deletes any containers it created if it runs completely. However, if you need to delete containers
// created by previous sessions (for example, if you interrupted the running code before it completed),
// you can uncomment and run the following line to delete them.

//await DeleteContainersWithPrefix(blobClient, ContainerPrefix);

// Return the service properties/storage analytics settings to their original values.
Expand All @@ -138,9 +136,6 @@ private static async Task CallBlobClientSamples(CloudBlobClient blobClient)
// Configure storage analytics (metrics and logging) on Blob storage.
await ConfigureBlobAnalyticsAsync(blobClient);

// Get geo-replication stats for Blob storage.
await GetServiceStatsForSecondaryAsync(blobClient);

// List all containers in the storage account.
ListAllContainers(blobClient, "sample-");

Expand Down Expand Up @@ -329,7 +324,7 @@ private static async Task ConfigureBlobAnalyticsAsync(CloudBlobClient blobClient
serviceProperties.MinuteMetrics.Version = "1.0";

// Set the default service version to be used for anonymous requests.
serviceProperties.DefaultServiceVersion = "2015-04-05";
serviceProperties.DefaultServiceVersion = "2018-11-09";

// Set the service properties.
await blobClient.SetServicePropertiesAsync(serviceProperties);
Expand All @@ -342,48 +337,6 @@ private static async Task ConfigureBlobAnalyticsAsync(CloudBlobClient blobClient
}
}

/// <summary>
/// Gets the Blob service stats for the secondary endpoint for an RA-GRS (read-access geo-redundant) storage account.
/// </summary>
/// <param name="blobClient">The Blob service client.</param>
/// <returns>A Task object.</returns>
private static async Task GetServiceStatsForSecondaryAsync(CloudBlobClient blobClient)
{
try
{
// Get the URI for the secondary endpoint for Blob storage.
Uri secondaryUri = blobClient.StorageUri.SecondaryUri;

// Create a new service client based on the secondary endpoint.
CloudBlobClient blobClientSecondary = new CloudBlobClient(secondaryUri, blobClient.Credentials);

// Get the current stats for the secondary.
// The call will fail if your storage account does not have RA-GRS enabled.
ServiceStats blobStats = await blobClientSecondary.GetServiceStatsAsync();

Console.WriteLine("Geo-replication status: {0}", blobStats.GeoReplication.Status);
Console.WriteLine("Last geo-replication sync time: {0}", blobStats.GeoReplication.LastSyncTime);
Console.WriteLine();
}
catch (StorageException e)
{
// In this case, we do not re-throw the exception, so that the sample will continue to run even if RA-GRS is not enabled
// for this storage account.
if (e.RequestInformation.HttpStatusCode == 403)
{
Console.WriteLine("This storage account does not appear to support RA-GRS.");
Console.WriteLine("More information: {0}", e.Message);
Console.WriteLine();
}
else
{
Console.WriteLine(e.Message);
Console.ReadLine();
throw;
}
}
}

/// <summary>
/// Lists all containers in the storage account.
/// Note that the ListContainers method is called synchronously, for the purposes of the sample. However, in a real-world
Expand Down
9 changes: 7 additions & 2 deletions BlobStorage/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Azure.KeyVault.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /></startup>
</configuration>
46 changes: 21 additions & 25 deletions BlobStorage/BlobStorage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BlobStorage</RootNamespace>
<AssemblyName>BlobStorage</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -33,40 +34,35 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Azure.KeyVault.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll</HintPath>
<Private>True</Private>
<Reference Include="Microsoft.Azure.ConfigurationManager, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Azure.ConfigurationManager.4.0.0\lib\net452\Microsoft.Azure.ConfigurationManager.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Data.Edm, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.Edm.5.7.0\lib\net40\Microsoft.Data.Edm.dll</HintPath>
<Private>True</Private>
<Reference Include="Microsoft.Azure.KeyVault.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Azure.KeyVault.Core.3.0.3\lib\net452\Microsoft.Azure.KeyVault.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Data.OData, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.OData.5.7.0\lib\net40\Microsoft.Data.OData.dll</HintPath>
<Private>True</Private>
<Reference Include="Microsoft.Azure.Storage.Blob, Version=10.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Azure.Storage.Blob.10.0.2\lib\net452\Microsoft.Azure.Storage.Blob.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Data.Services.Client, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.Services.Client.5.7.0\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
<Private>True</Private>
<Reference Include="Microsoft.Azure.Storage.Common, Version=10.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Azure.Storage.Common.10.0.2\lib\net452\Microsoft.Azure.Storage.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Configuration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.WindowsAzure.ConfigurationManager.3.2.1\lib\net40\Microsoft.WindowsAzure.Configuration.dll</HintPath>
<Private>True</Private>
<Reference Include="Microsoft.Data.Edm, Version=5.8.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.Edm.5.8.4\lib\net40\Microsoft.Data.Edm.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Storage, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\WindowsAzure.Storage.7.0.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
<Private>True</Private>
<Reference Include="Microsoft.Data.OData, Version=5.8.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.OData.5.8.4\lib\net40\Microsoft.Data.OData.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
<Reference Include="Microsoft.Data.Services.Client, Version=5.8.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.Services.Client.5.8.4\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Spatial, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.Spatial.5.7.0\lib\net40\System.Spatial.dll</HintPath>
<Private>True</Private>
<Reference Include="System.Spatial, Version=5.8.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.Spatial.5.8.4\lib\net40\System.Spatial.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
Expand Down
2 changes: 1 addition & 1 deletion BlobStorage/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace BlobStorage
{
using System;
using Microsoft.Azure;
using Microsoft.WindowsAzure.Storage;
using Microsoft.Azure.Storage;

/// <summary>
/// Contains public method for validating the storage connection string.
Expand Down
8 changes: 4 additions & 4 deletions BlobStorage/GettingStarted.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ namespace BlobStorage
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Blob;
using Microsoft.WindowsAzure.Storage.RetryPolicies;
using Microsoft.Azure.Storage;
using Microsoft.Azure.Storage.Auth;
using Microsoft.Azure.Storage.Blob;
using Microsoft.Azure.Storage.RetryPolicies;

/// <summary>
/// Getting started samples for Blob storage
Expand Down
2 changes: 1 addition & 1 deletion BlobStorage/WCFBufferManagerAdapter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.ServiceModel.Channels;
using Microsoft.WindowsAzure.Storage;
using Microsoft.Azure.Storage;

namespace BlobStorage
{
Expand Down
17 changes: 9 additions & 8 deletions BlobStorage/packages.config
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net452" />
<package id="Microsoft.Data.Edm" version="5.7.0" targetFramework="net452" />
<package id="Microsoft.Data.OData" version="5.7.0" targetFramework="net452" />
<package id="Microsoft.Data.Services.Client" version="5.7.0" targetFramework="net452" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.2.1" targetFramework="net452" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net452" />
<package id="System.Spatial" version="5.7.0" targetFramework="net452" />
<package id="WindowsAzure.Storage" version="7.0.0" targetFramework="net452" />
<package id="Microsoft.Azure.ConfigurationManager" version="4.0.0" targetFramework="net452" />
<package id="Microsoft.Azure.KeyVault.Core" version="3.0.3" targetFramework="net452" />
<package id="Microsoft.Azure.Storage.Blob" version="10.0.2" targetFramework="net472" />
<package id="Microsoft.Azure.Storage.Common" version="10.0.2" targetFramework="net472" />
<package id="Microsoft.Data.Edm" version="5.8.4" targetFramework="net452" />
<package id="Microsoft.Data.OData" version="5.8.4" targetFramework="net452" />
<package id="Microsoft.Data.Services.Client" version="5.8.4" targetFramework="net452" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net452" />
<package id="System.Spatial" version="5.8.4" targetFramework="net452" />
</packages>