Created
May 29, 2016 20:48
-
-
Save buchizo/71d6f16cb623ee764186985d1881b1b9 to your computer and use it in GitHub Desktop.
Azure Function QueueTriggerCSharp sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
...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 --- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public static void Run(string myQueueItem, out string outputBlob, TraceWriter log) | |
{ | |
outputBlob = myQueueItem; | |
} |
Author
buchizo
commented
May 29, 2016
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