Skip to content

Commit

Permalink
Storage API Changes (Part 2 - Simplify the Storage user experience) (#…
Browse files Browse the repository at this point in the history
…6749)

Add simple Upload, Download, and BlobClient
  • Loading branch information
tg-msft authored Jul 2, 2019
1 parent bc7c784 commit 96877bd
Show file tree
Hide file tree
Showing 564 changed files with 118,105 additions and 4,486 deletions.
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core/tests/ClientTestBaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void ThrowsForSyncCallsInAsyncContext()
{
var client = InstrumentClient(new TestClient());
var exception = Assert.Throws<InvalidOperationException>(() => client.Method(123));
Assert.AreEqual("Async method call expected", exception.Message);
Assert.AreEqual("Async method call expected for Method", exception.Message);
}
}

Expand Down
3 changes: 3 additions & 0 deletions sdk/core/Azure.Core/tests/TestFramework/ClientTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

using System;
using System.Diagnostics;
using System.Reflection;
using Castle.DynamicProxy;
using NUnit.Framework;
Expand Down Expand Up @@ -32,6 +33,8 @@ public virtual TClient CreateClient<TClient>(params object[] args) where TClient

public virtual TClient InstrumentClient<TClient>(TClient client) where TClient: class
{
Debug.Assert(!client.GetType().Name.EndsWith("Proxy"), $"{nameof(client)} was already instrumented");

if (ClientValidation<TClient>.Validated == false)
{
foreach (var methodInfo in typeof(TClient).GetMethods(BindingFlags.Instance | BindingFlags.Public))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void Intercept(IInvocation invocation)
// Check if there is an async alternative to sync call
if (asyncAlternative != null)
{
throw new InvalidOperationException("Async method call expected");
throw new InvalidOperationException($"Async method call expected for {methodName}");
}
else
{
Expand Down
14 changes: 7 additions & 7 deletions sdk/storage/Azure.Storage.Blobs/src/AppendBlobClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace Azure.Storage.Blobs.Specialized
/// maximum size of an append blob is therefore slightly more than 195 GB
/// (4 MB X 50,000 blocks).
/// </summary>
public class AppendBlobClient : BlobClient
public class AppendBlobClient : BlobBaseClient
{
/// <summary>
/// <see cref="AppendBlobMaxAppendBlockBytes"/> indicates the maximum
Expand Down Expand Up @@ -546,15 +546,16 @@ private async Task<Response<BlobAppendInfo>> AppendBlockAsync(
{
content = content.WithNoDispose().WithProgress(progressHandler);
var appendAttempt = 0;
return await ReliableOperation.DoAsync(
return await ReliableOperation.DoSyncOrAsync(
async,
reset: () => content.Seek(0, SeekOrigin.Begin),
predicate: e => true,
maximumRetries: Constants.MaxReliabilityRetries,
operation:
async () =>
() =>
{
this.Pipeline.LogTrace($"Append attempt {++appendAttempt}");
return await BlobRestClient.AppendBlob.AppendBlockAsync(
return BlobRestClient.AppendBlob.AppendBlockAsync(
this.Pipeline,
this.Uri,
body: content,
Expand All @@ -568,8 +569,7 @@ private async Task<Response<BlobAppendInfo>> AppendBlockAsync(
ifMatch: accessConditions?.HttpAccessConditions?.IfMatch,
ifNoneMatch: accessConditions?.HttpAccessConditions?.IfNoneMatch,
async: async,
cancellationToken: cancellationToken)
.ConfigureAwait(false);
cancellationToken: cancellationToken);
},
cleanup: () => { })
.ConfigureAwait(false);
Expand Down Expand Up @@ -854,6 +854,6 @@ public static partial class SpecializedBlobExtensions
public static AppendBlobClient GetAppendBlobClient(
this BlobContainerClient client,
string blobName)
=> new AppendBlobClient(client.Uri.AppendToPath(blobName), client._pipeline);
=> new AppendBlobClient(client.Uri.AppendToPath(blobName), client.Pipeline);
}
}
Loading

0 comments on commit 96877bd

Please sign in to comment.