public async Task ErrorsAsync()
        {
            // Get a connection string to our Azure Storage account
            string connectionString = ConnectionString;

            // Get a reference to a queue named "sample-queue" and then create it
            QueueClient queue = new QueueClient(connectionString, Randomize("sample-queue"));
            await queue.CreateAsync();

            try
            {
                // Try to create the queue again
                await queue.CreateAsync();
            }
            catch (RequestFailedException ex)
                when(ex.ErrorCode == QueueErrorCode.QueueAlreadyExists)
                {
                    // Ignore any errors if the queue already exists
                }
            catch (RequestFailedException ex)
            {
                Assert.Fail($"Unexpected error: {ex}");
            }

            // Clean up after the test when we're finished
            await queue.DeleteAsync();
        }
        public async Task MessageSample()
        {
            // Instantiate a new QueueServiceClient using a connection string.
            QueueServiceClient queueServiceClient = new QueueServiceClient(TestConfigurations.DefaultTargetTenant.ConnectionString);

            // Instantiate a new QueueClient
            QueueClient queueClient = queueServiceClient.GetQueueClient($"myqueue2-{Guid.NewGuid()}");

            try
            {
                // Create your new Queue in the service
                await queueClient.CreateAsync();

                // Instantiate a new MessagesClient
                // Enqueue a message to the queue
                Response <EnqueuedMessage> enqueueResponse = await queueClient.EnqueueMessageAsync("my message");

                // Peek message
                Response <IEnumerable <PeekedMessage> > peekResponse = await queueClient.PeekMessagesAsync();

                // Update message
                await queueClient.UpdateMessageAsync("new message", enqueueResponse.Value.MessageId, enqueueResponse.Value.PopReceipt);

                // Dequeue message
                Response <IEnumerable <DequeuedMessage> > dequeueResponse = await queueClient.DequeueMessagesAsync();

                // Delete Message
                await queueClient.DeleteMessageAsync(enqueueResponse.Value.MessageId, dequeueResponse.Value.First().PopReceipt);
            }
            finally
            {
                // Delete your Queue in the service
                await queueClient.DeleteAsync();
            }
        }
        /// <summary>
        /// Create a queue and add a message.
        /// </summary>
        /// <param name="connectionString">
        /// A connection string to your Azure Storage account.
        /// </param>
        /// <param name="queueName">
        /// The name of the queue to create and send a message to.
        /// </param>
        public static async Task SendMessageAsync(string connectionString, string queueName)
        {
            // We'll need a connection string to your Azure Storage account.
            // You can obtain your connection string from the Azure Portal
            // (click Access Keys under Settings in the Portal Storage account
            // blade) or using the Azure CLI with:
            //
            //     az storage account show-connection-string --name <account_name> --resource-group <resource_group>
            //
            // You would normally provide the connection string to your
            // application using an environment variable.

            #region Snippet:Azure_Storage_Queues_Samples_Sample01b_HelloWorld_SendMessageAsync
            // We'll need a connection string to your Azure Storage account.
            //@@ string connectionString = "<connection_string>";

            // Name of the queue we'll send messages to
            //@@ string queueName = "sample-queue";

            // Get a reference to a queue and then create it
            QueueClient queue = new QueueClient(connectionString, queueName);
            await queue.CreateAsync();

            // Send a message to our queue
            await queue.SendMessageAsync("Hello, Azure!");

            #endregion Snippet:Azure_Storage_Queues_Samples_Sample01b_HelloWorld_SendMessageAsync
        }
예제 #4
0
        public static async Task Main(string[] args)
        {
            Console.WriteLine("Hello MessageProcessor");

            QueueClient client = new QueueClient(storageConnectionString, queueName);
            await client.CreateAsync();

            Console.WriteLine($"---Account Metadata---");
            Console.WriteLine($"Account Uri:\t{client.Uri}");
            //Console.WriteLine($"---Existing Messages---");
            int      batchSize         = 10;
            TimeSpan visibilityTimeout = TimeSpan.FromSeconds(2.5d);

            Response <QueueMessage[]> messages = await client.ReceiveMessagesAsync(batchSize, visibilityTimeout);

            Console.WriteLine($"type of <messages> is {messages.GetType()}");
            //**************************************************************************
            //if(messages?.MessageId? == null)	Console.WriteLine("\nno messages\n");
            if (messages.Value.ToString() == "Azure.Storage.Queues.Models.QueueMessage[]")
            {
                Console.WriteLine("\npredicate is <<messages.Value.ToString()>>\n");
            }
            if (messages.Value.Length == 0)
            {
                Console.WriteLine("\nno messages\n");
            }
            //**************************************************************************
            //foreach(QueueMessage message in messages?.Value)
            //Console.WriteLine($"[{message.MessageId}]\t{message.MessageText}");
            foreach (QueueMessage message in messages?.Value)
            {
                Console.WriteLine($"[{message.MessageId}]\t{message.MessageText}");
                await client.DeleteMessageAsync(message.MessageId, message.PopReceipt);
            }
        }
예제 #5
0
    public static async Task Main(string[] args)
    {
        QueueClient client = new QueueClient(storageConnectionString, queueName);
        await client.CreateAsync();

        Console.WriteLine($"---Account Metdata---");
        Console.WriteLine($"Account Uri:\t{client.Uri}");

        Console.WriteLine($"---Existing Messages---");
        int      batchSize         = 10;
        TimeSpan visibilityTimeout = TimeSpan.FromSeconds(2.5d);

        Response <QueueMessage[]> messages = await client.ReceiveMessagesAsync(batchSize, visibilityTimeout);

        foreach (QueueMessage message in messages?.Value)
        {
            Console.WriteLine($"[{message.MessageId}]\t{message.MessageText}");
            await client.DeleteMessageAsync(message.MessageId, message.PopReceipt);
        }

        Console.WriteLine($"---New Messages---");
        string greeting = "Hi, Developer!";
        await client.SendMessageAsync(greeting);

        Console.WriteLine($"Sent Message:\t{greeting}");
    }
        public static async Task <SendReceipt> AddMessageAndCreateIfNotExistsAsync(this QueueClient queue,
                                                                                   string message, CancellationToken cancellationToken)
        {
            if (queue == null)
            {
                throw new ArgumentNullException(nameof(queue));
            }

            bool isQueueNotFoundException = false;

            SendReceipt receipt = null;

            try
            {
                receipt = await queue.SendMessageAsync(message, cancellationToken).ConfigureAwait(false);

                return(receipt);
            }
            catch (RequestFailedException exception)
            {
                if (!exception.IsNotFoundQueueNotFound())
                {
                    throw;
                }

                isQueueNotFoundException = true;
            }

            Debug.Assert(isQueueNotFoundException);
            await queue.CreateAsync(cancellationToken : cancellationToken).ConfigureAwait(false);

            receipt = await queue.SendMessageAsync(message, cancellationToken).ConfigureAwait(false);

            return(receipt);
        }
        public async Task QueueSample()
        {
            // Instantiate a new QueueServiceClient using a connection string.
            QueueServiceClient queueServiceClient = new QueueServiceClient(TestConfigurations.DefaultTargetTenant.ConnectionString);

            // Instantiate a new QueueClient
            QueueClient queueClient = queueServiceClient.GetQueueClient($"myqueue-{Guid.NewGuid()}");

            try
            {
                // Create your new Queue in the service
                await queueClient.CreateAsync();

                // List Queues
                await foreach (QueueItem queue in queueServiceClient.GetQueuesAsync())
                {
                    Console.WriteLine(queue.Name);
                }
            }
            finally
            {
                // Delete your Queue in the service
                await queueClient.DeleteAsync();
            }
        }
        public async Task EnqueueAsync()
        {
            // Get a connection string to our Azure Storage account.  You can
            // obtain your connection string from the Azure Portal (click
            // Access Keys under Settings in the Portal Storage account blade)
            // or using the Azure CLI with:
            //
            //     az storage account show-connection-string --name <account_name> --resource-group <resource_group>
            //
            // And you can provide the connection string to your application
            // using an environment variable.
            string connectionString = ConnectionString;

            // Get a reference to a queue named "sample-queue" and then create it
            QueueClient queue = new QueueClient(connectionString, Randomize("sample-queue"));
            await queue.CreateAsync();

            try
            {
                // Add a message to our queue
                await queue.SendMessageAsync("Hello, Azure!");

                // Verify we uploaded one message
                Assert.AreEqual(1, (await queue.PeekMessagesAsync(10)).Value.Count());
            }
            finally
            {
                // Clean up after the test when we're finished
                await queue.DeleteAsync();
            }
        }
예제 #9
0
        private static async Task <QueueClient> CreateClientAsync(AzureOptions options)
        {
            var client = new QueueClient(options.ConnectionString, options.QueueName);

            await client.CreateAsync();

            return(client);
        }
예제 #10
0
        private async Task <QueueClient> GetQueueClient(string QueueName)
        {
            QueueClient queue = new QueueClient(_AzureStorageConnectionString, QueueName);

            await queue.CreateAsync();

            return(queue);
        }
예제 #11
0
        static async Task Main(string[] args)
        {
            ISerializer serializer    = new Serializer();
            var         loggerFactory = LoggerFactory.Create(builder =>
            {
                builder
                .AddFilter("Microsoft", LogLevel.Warning)
                .AddFilter("System", LogLevel.Warning)
                .AddFilter("LoggingConsoleApp.Program", LogLevel.Debug)
                .AddConsole()
                .AddEventLog();
            });
            ILogger logger = loggerFactory.CreateLogger <Program>();

            var connectionStringKeyVaultFetchStore = new SimpleStringKeyVaultFetchStore(
                new KeyVaultFetchStoreOptions <string>()
            {
                ExpirationSeconds = 3600,
                KeyVaultName      = "kv-queueflow",
                SecretName        = "stazfuncqueueflow-primary-connection-string"
            }, logger);

            var connectionString = await connectionStringKeyVaultFetchStore.GetStringValueAsync();



            var accountName = "stazfuncqueueflow";
            var queueName   = "queue-main";

            string queueUri = $"https://{accountName}.queue.core.windows.net/{queueName}";

            // Get a credential and create a client object for the blob container.
            //           QueueClient queueClient = new QueueClient(new Uri(queueUri),new DefaultAzureCredential());
            QueueClient queueClient = new QueueClient(connectionString, queueName);
            // Create the queue
            await queueClient.CreateAsync();


            while (true)
            {
                QueueMessage[] messages = await queueClient.ReceiveMessagesAsync(maxMessages : 10);

                // Process and delete messages from the queue
                foreach (QueueMessage message in messages)
                {
                    var decoded = message.MessageText.Base64Decode();
                    // "Process" the message
                    Console.WriteLine($"Message: {message.MessageText} - {decoded}");
                    var job = serializer.Deserialize <Job>(decoded);

                    // Let the service know we're finished with
                    // the message and it can be safely deleted.
                    await queueClient.DeleteMessageAsync(message.MessageId, message.PopReceipt);
                }

                Thread.Sleep(1000);
            }
        }
예제 #12
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("Azure Queue Storage client library v12 - .NET quickstart sample\n");
// another comment,  testing github
// Changed this andded a line.
//Retrieve the connection string for use with the application. The storage
// connection string is stored in an environment variable called
// AZURE_STORAGE_CONNECTION_STRING on the machine running the application.
// If the environment variable is created after the application is launched
// in a console or with Visual Studio, the shell or application needs to be
// closed and reloaded to take the environment variable into account.
            string connectionString = Environment.GetEnvironmentVariable("AZURE_STORAGE_CONNECTION_STRING");

//get number of people and create queue for each
            Console.WriteLine("How many people in this shift?");
            int shifters = System.Console.ReadLine();

            Console.WriteLine($"Ok creating setup for {shifters} staff.");

// Create a unique name for the queue

            string queueName = "dispatch-rd-quickstartqueues-" + Guid.NewGuid().ToString();
            string queueName = "dispatch-rd-quickstartqueues-" + Guid.NewGuid().ToString();
            string queueName = "dispatch-rd-quickstartqueues-" + Guid.NewGuid().ToString();

            Console.WriteLine($"Creating queue: {queueName}");

// Instantiate a QueueClient which will be
// used to create and manipulate the queue
            QueueClient queueClient = new QueueClient(connectionString, queueName);

// Create the queue
            await queueClient.CreateAsync();

            Console.WriteLine("\nAdding messages to the queue...");

// Send several messages to the queue
            await queueClient.SendMessageAsync("First message");

            await queueClient.SendMessageAsync("Second message");

// Save the receipt so we can update this message later
            SendReceipt receipt = await queueClient.SendMessageAsync("Third message");

            Console.WriteLine("\nPeek at the messages in the queue...");

// Peek at messages in the queue
            PeekedMessage[] peekedMessages = await queueClient.PeekMessagesAsync(maxMessages : 10);

            foreach (PeekedMessage peekedMessage in peekedMessages)
            {
                // Display the message
                Console.WriteLine($"Message: {peekedMessage.MessageText}");
            }
        }
예제 #13
0
        public static async Task TestWithQueue(string accountName, string queueName, string message)
        {
            var uri   = new Uri($"https://{accountName}.queue.core.windows.net/{queueName}");
            var queue = new QueueClient(uri, new DefaultAzureCredential());

            Console.WriteLine($@"calling CreateAsync() on ""{uri}""");
            await queue.CreateAsync();

            Console.WriteLine($@"calling EnqueueMessageAsync(""{message}"") on ""{uri}""");
            await queue.EnqueueMessageAsync(message);
        }
        public async Task Capture_Span_When_Send_To_Queue()
        {
            var queueName      = Guid.NewGuid().ToString();
            var client         = new QueueClient(_environment.StorageAccountConnectionString, queueName);
            var createResponse = await client.CreateAsync();

            await _agent.Tracer.CaptureTransaction("Send Azure Queue Message", "message", async() =>
            {
                var sendResponse = await client.SendMessageAsync(nameof(Capture_Span_When_Send_To_Queue));
            });

            AssertSpan("SEND", queueName);
        }
예제 #15
0
 public async static Task CreateQueuesIfNotExistsAsync(string queueName = null)
 {
     if (StorageConnectionType == StorageConnectionType.Key)
     {
         var auditQueue = new QueueClient(new Uri($"{StorageName}.queue.core.windows.net/{queueName ?? QueueName}"), new Azure.Storage.StorageSharedKeyCredential(StorageName, ConnectionKey));
         await auditQueue.CreateIfNotExistsAsync();
     }
     else
     {
         var auditQueue = new QueueClient(ConnectionKey, queueName ?? QueueName);
         await auditQueue.CreateAsync();
     }
 }
        public async Task Capture_Span_When_Receive_From_Queue()
        {
            var queueName = Guid.NewGuid().ToString();
            var client    = new QueueClient(_environment.StorageAccountConnectionString, queueName);

            var createResponse = await client.CreateAsync();

            var sendResponse = await client.SendMessageAsync(nameof(Capture_Span_When_Receive_From_Queue));

            var receiveResponse = await client.ReceiveMessageAsync();

            AssertTransaction("RECEIVE", queueName);
        }
        public async Task DequeueAndUpdateAsync()
        {
            // Get a connection string to our Azure Storage account.
            string connectionString = ConnectionString;

            // Get a reference to a queue named "sample-queue" and then create it
            QueueClient queue = new QueueClient(connectionString, Randomize("sample-queue"));
            await queue.CreateAsync();

            try
            {
                // Add several messages to the queue
                await queue.SendMessageAsync("first");

                await queue.SendMessageAsync("second");

                await queue.SendMessageAsync("third");

                // Get the messages from the queue with a short visibility timeout
                List <QueueMessage> messages = new List <QueueMessage>();
                foreach (QueueMessage message in (await queue.ReceiveMessagesAsync(10, TimeSpan.FromSeconds(1))).Value)
                {
                    // Tell the service we need a little more time to process the message
                    UpdateReceipt changedMessage = await queue.UpdateMessageAsync(
                        message.MessageId,
                        message.PopReceipt,
                        message.MessageText,
                        TimeSpan.FromSeconds(5));

                    messages.Add(message.Update(changedMessage));
                }

                // Wait until the visibility window times out
                await Task.Delay(TimeSpan.FromSeconds(1.5));

                // Ensure the messages aren't visible yet
                Assert.AreEqual(0, (await queue.ReceiveMessagesAsync(10)).Value.Count());

                // Finish processing the messages
                foreach (QueueMessage message in messages)
                {
                    // Tell the service we need a little more time to process the message
                    await queue.DeleteMessageAsync(message.MessageId, message.PopReceipt);
                }
            }
            finally
            {
                // Clean up after the test when we're finished
                await queue.DeleteAsync();
            }
        }
 /// <summary>
 /// Trigger a recoverable error.
 /// </summary>
 /// <param name="connectionString">
 /// A connection string to your Azure Storage account.
 /// </param>
 /// <param name="queueName">
 /// The name of an existing queue to operate on.
 /// </param>
 public static async Task ErrorsAsync(string connectionString, string queueName)
 {
     try
     {
         // Try to create a queue that already exists
         QueueClient queue = new QueueClient(connectionString, queueName);
         await queue.CreateAsync();
     }
     catch (RequestFailedException ex)
         when(ex.ErrorCode == QueueErrorCode.QueueAlreadyExists)
         {
             // Ignore any errors if the queue already exists
         }
 }
        public async Task DequeueAsync()
        {
            // Get a connection string to our Azure Storage account.
            string connectionString = ConnectionString;

            // Get a reference to a queue named "sample-queue" and then create it
            QueueClient queue = new QueueClient(connectionString, Randomize("sample-queue"));
            await queue.CreateAsync();

            try
            {
                // Add several messages to the queue
                await queue.SendMessageAsync("first");

                await queue.SendMessageAsync("second");

                await queue.SendMessageAsync("third");

                await queue.SendMessageAsync("fourth");

                await queue.SendMessageAsync("fifth");

                // Get the messages from the queue
                List <string> messages = new List <string>();
                foreach (QueueMessage message in (await queue.ReceiveMessagesAsync(maxMessages: 10)).Value)
                {
                    // "Process" the message
                    messages.Add(message.MessageText);

                    // Let the service know we finished with the message and
                    // it can be safely deleted.
                    await queue.DeleteMessageAsync(message.MessageId, message.PopReceipt);
                }

                // Verify the messages
                Assert.AreEqual(5, messages.Count);
                Assert.Contains("first", messages);
                Assert.Contains("second", messages);
                Assert.Contains("third", messages);
                Assert.Contains("fourth", messages);
                Assert.Contains("fifth", messages);
            }
            finally
            {
                // Clean up after the test when we're finished
                await queue.DeleteAsync();
            }
        }
예제 #20
0
        public static async Task MainAsync()
        {
            //Create Queue
            string connectionString = "";
            // Create a unique name for the queue
            string queueName = "quickstartqueues";

            Console.WriteLine($"Creating queue: {queueName}");

            // Instantiate a QueueClient which will be
            // used to create and manipulate the queue
            QueueClient queueClient = new QueueClient(connectionString, queueName);

            // Create the queue
            await queueClient.CreateAsync();
        }
        public async Task Sample01b_HelloWorldAsync_ErrorsAsync()
        {
            string      queueName = Randomize("sample-queue");
            QueueClient queue     = new QueueClient(ConnectionString, queueName);

            try
            {
                await queue.CreateAsync();

                await Sample01b_HelloWorldAsync.ErrorsAsync(ConnectionString, queueName);
            }
            finally
            {
                await queue.DeleteAsync();
            }
        }
예제 #22
0
        static async Task Main(string[] args)
        {
            QueueClient client = new QueueClient(storageConnectionString, queueName);
            await client.CreateAsync();

            await Console.Out.WriteLineAsync($"Account Uri:\t{client.Uri}");

            int      batchSize         = 10;
            TimeSpan visibilityTimeout = TimeSpan.FromSeconds(2.5d);

            Response <QueueMessage[]> messages = await client.ReceiveMessagesAsync(batchSize, visibilityTimeout);

            foreach (QueueMessage message in messages?.Value)
            {
                Console.WriteLine($"[{message.MessageId}]\t{message.MessageText}");
            }
        }
예제 #23
0
        public async Task PeekAsync()
        {
            // Get a connection string to our Azure Storage account.
            string connectionString = ConnectionString;

            // Get a reference to a queue named "sample-queue" and then create it
            QueueClient queue = new QueueClient(connectionString, Randomize("sample-queue"));
            await queue.CreateAsync();

            try
            {
                // Add several messages to the queue
                await queue.EnqueueMessageAsync("first");

                await queue.EnqueueMessageAsync("second");

                await queue.EnqueueMessageAsync("third");

                await queue.EnqueueMessageAsync("fourth");

                await queue.EnqueueMessageAsync("fifth");

                // Get the messages from the queue
                List <string> messages = new List <string>();
                foreach (PeekedMessage message in (await queue.PeekMessagesAsync(maxMessages: 10)).Value)
                {
                    // Inspect the message
                    messages.Add(message.MessageText);
                }

                // Verify the messages
                Assert.AreEqual(5, messages.Count);
                Assert.Contains("first", messages);
                Assert.Contains("second", messages);
                Assert.Contains("third", messages);
                Assert.Contains("fourth", messages);
                Assert.Contains("fifth", messages);
            }
            finally
            {
                // Clean up after the test when we're finished
                await queue.DeleteAsync();
            }
        }
        public async Task Sample01b_HelloWorldAsync_ReceiveMessagesAsync()
        {
            string      queueName = Randomize("sample-queue");
            QueueClient queue     = new QueueClient(ConnectionString, queueName);

            try
            {
                await queue.CreateAsync();

                await Sample01b_HelloWorldAsync.ReceiveMessagesAsync(ConnectionString, queueName);

                // Verify we processed all the messages
                Assert.AreEqual(0, (await queue.PeekMessagesAsync()).Value.Length);
            }
            finally
            {
                await queue.DeleteAsync();
            }
        }
        public async Task CreateQueue(string queueName)
        {
            try
            {
                // Try to create a queue that already exists
                var queueClient = new QueueClient(_connectionString, queueName);
                await queueClient.CreateAsync();
            }
            catch (RequestFailedException ex) when(ex.ErrorCode == QueueErrorCode.QueueAlreadyExists)
            {
                _logger.LogError(ex, ex.Message);

                // Ignore any errors if the queue already exists
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task Sample01b_HelloWorldAsync_PeekMesssagesAsync()
        {
            string      queueName = Randomize("sample-queue");
            QueueClient queue     = new QueueClient(ConnectionString, queueName);

            try
            {
                await queue.CreateAsync();

                await Sample01b_HelloWorldAsync.PeekMesssagesAsync(ConnectionString, queueName);

                // Verify we haven't emptied the queue
                Assert.Less(0, (await queue.PeekMessagesAsync()).Value.Length);
            }
            finally
            {
                await queue.DeleteAsync();
            }
        }
        public static async Task Main(string[] args)
        {
            QueueClient client = new QueueClient(storageConnectionString, queueName);
            await client.CreateAsync();

            await Console.Out.WriteLineAsync($"---Account Metadata---");

            await Console.Out.WriteLineAsync($"Account Uri:\t{client.Uri}");

            await ReadExistingMessages(client);

            await Console.Out.WriteLineAsync($"---New Messages---");

            string greeting = "Hi, Developer!";
            await client.SendMessageAsync(greeting);

            Console.WriteLine($"Sent Message:\t{greeting}");

            await ReadExistingMessages(client);
        }
예제 #28
0
        public async Task QueueSample()
        {
            // Instantiate a new QueueServiceClient using a connection string.
            QueueServiceClient queueServiceClient = new QueueServiceClient(TestConfigurations.DefaultTargetTenant.ConnectionString);

            // Instantiate a new QueueClient
            QueueClient queueClient = queueServiceClient.GetQueueClient("myqueue");

            try
            {
                // Create your new Queue in the service
                await queueClient.CreateAsync();

                // List Queues
                Response <QueuesSegment> listResponse = await queueServiceClient.ListQueuesSegmentAsync();
            }
            finally
            {
                // Delete your Queue in the service
                await queueClient.DeleteAsync();
            }
        }
예제 #29
0
        public static async Task Main(string[] args)
        {
            var client = new QueueClient(storageConnectionString, queueName);
            await client.CreateAsync();

            Console.WriteLine("---Account Metadata");
            Console.WriteLine($"Account Uri:\t{client.Uri}");

            var greeting = "Hi, Devs ";
            await client.SendMessageAsync(greeting);

            Console.WriteLine("---Existing Messages");
            var batchSize         = 10;
            var visibilityTimeout = TimeSpan.FromSeconds(2.5d);

            var messages = await client.ReceiveMessagesAsync(batchSize, visibilityTimeout);

            foreach (var message in messages?.Value)
            {
                Console.WriteLine($"[{message.MessageId}]\t{message.MessageText}");
                await client.DeleteMessageAsync(message.MessageId, message.PopReceipt);
            }
        }
예제 #30
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req, ExecutionContext executionContext,
            ILogger log)
        {
            var config = new ConfigurationBuilder()
                         .SetBasePath(executionContext.FunctionAppDirectory)
                         .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
                         .AddEnvironmentVariables()
                         .Build();


            string      connectionString = config["StorageAccountConnectionString"];
            string      queueName        = "employeesqueue";
            QueueClient queueClient      = new QueueClient(connectionString, queueName);

            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();

            await queueClient.CreateAsync();

            await queueClient.SendMessageAsync(Base64Encode(requestBody));

            return(new OkObjectResult(requestBody));
        }