Skip to content

Instantly share code, notes, and snippets.

@buchizo
Created May 29, 2016 20:48
Show Gist options
  • Save buchizo/71d6f16cb623ee764186985d1881b1b9 to your computer and use it in GitHub Desktop.
Save buchizo/71d6f16cb623ee764186985d1881b1b9 to your computer and use it in GitHub Desktop.
Azure Function QueueTriggerCSharp sample
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Queue;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BulkQueue
{
class Program
{
static readonly string Account = "<storage account name>";
static readonly string Key = "<storage account key>";
static readonly string QueueName = "samplequeue";
static void Main(string[] args)
{
var credential = new StorageCredentials(Account, Key);
var tasks = Enumerable.Range(1, 300)
.Select(i =>
{
return Task.Run(() =>
{
var account = new CloudStorageAccount(credential, true);
var client = account.CreateCloudQueueClient();
var queue = client.GetQueueReference(QueueName);
var content = $"HelloWorld_{i}";
var message = new CloudQueueMessage(content);
queue.AddMessage(message);
Console.WriteLine(i);
});
});
Task.WaitAll(tasks.ToArray());
Console.WriteLine("Hit any key.");
Console.ReadKey();
}
}
}
...at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.WebJobs.Host.Blobs.Bindings.WatchableCloudBlobStream.<CommitAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.WebJobs.Host.Blobs.Bindings.OutStringArgumentBindingProvider.StringArgumentBinding.StringValueBinder.<SetValueAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.<ExecuteWithWatchersAsync>d__33.MoveNext()
--- End of inner exception stack trace ---
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.<ExecuteWithWatchersAsync>d__33.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.<ExecuteWithLoggingAsync>d__2e.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.<ExecuteWithLoggingAsync>d__15.MoveNext()
--- End of inner exception stack trace ---
{
"bindings": [
{
"name": "myQueueItem",
"type": "queueTrigger",
"direction": "in",
"queueName": "samplequeue",
"connection": "buchifunctions_STORAGE"
},
{
"type": "blob",
"name": "outputBlob",
"path": "outcontainer/%rand-int%{queueTrigger}.txt",
"connection": "buchifunctions_STORAGE",
"direction": "out"
}
],
"disabled": false
}
using System;
public static void Run(string myQueueItem, out string outputBlob, TraceWriter log)
{
outputBlob = myQueueItem;
}
@buchizo
Copy link
Author

buchizo commented May 29, 2016

image

@pragnagopa
Copy link

I am unable to repro this issue. @buchizo - Can you try it with latest runtime and let us know if you still see this error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment