public static WaitForBlobAndGetStringAsync ( Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob blob ) : Task |
||
blob | Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob | |
Résultat | Task |
public async Task HttpTrigger_CSharp_Poco_Post_Succeeds() { string uri = "api/httptrigger-csharp-poco?code=zlnu496ve212kk1p84ncrtdvmtpembduqp25ajjc"; HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, uri); string id = Guid.NewGuid().ToString(); JObject requestBody = new JObject { { "Id", id }, { "Value", "Testing" } }; request.Content = new StringContent(requestBody.ToString()); request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = await this._fixture.HttpClient.SendAsync(request); Assert.Equal(HttpStatusCode.OK, response.StatusCode); // wait for function to execute and produce its result blob CloudBlobContainer outputContainer = _fixture.BlobClient.GetContainerReference("samples-output"); CloudBlockBlob outputBlob = outputContainer.GetBlockBlobReference(id); string result = await TestHelpers.WaitForBlobAndGetStringAsync(outputBlob); Assert.Equal("Testing", TestHelpers.RemoveByteOrderMarkAndWhitespace(result)); }
public async Task ManualTrigger_Invoke_Succeeds() { CloudBlobContainer outputContainer = _fixture.BlobClient.GetContainerReference("samples-output"); CloudBlockBlob outputBlob = outputContainer.GetBlockBlobReference("result"); outputBlob.DeleteIfExists(); CloudBlobContainer inputContainer = _fixture.BlobClient.GetContainerReference("samples-input"); CloudBlockBlob statusBlob = inputContainer.GetBlockBlobReference("status"); statusBlob.UploadText("{ \"level\": 4, \"detail\": \"All systems are normal :)\" }"); string uri = "admin/functions/manualtrigger"; HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, uri); request.Headers.Add("x-functions-key", "t8laajal0a1ajkgzoqlfv5gxr4ebhqozebw4qzdy"); request.Content = new StringContent("{ 'input': 'Hello Manual Trigger!' }"); request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = await this._fixture.HttpClient.SendAsync(request); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); // wait for completion string result = await TestHelpers.WaitForBlobAndGetStringAsync(outputBlob); Assert.Equal("All systems are normal :)", result); }
protected async Task ServiceBusQueueTriggerToBlobTestImpl() { var resultBlob = Fixture.TestOutputContainer.GetBlockBlobReference("completed"); await resultBlob.DeleteIfExistsAsync(); string id = Guid.NewGuid().ToString(); JObject message = new JObject { { "count", 0 }, { "id", id } }; using (Stream stream = new MemoryStream()) using (TextWriter writer = new StreamWriter(stream)) { writer.Write(message.ToString()); writer.Flush(); stream.Position = 0; await Fixture.ServiceBusQueueClient.SendAsync(new BrokeredMessage(stream) { ContentType = "text/plain" }); } // now wait for function to be invoked string result = await TestHelpers.WaitForBlobAndGetStringAsync(resultBlob); Assert.Equal(TestHelpers.RemoveByteOrderMarkAndWhitespace(id), TestHelpers.RemoveByteOrderMarkAndWhitespace(result)); }
public async Task QueueTriggerToBlobTest() { TestHelpers.ClearFunctionLogs("QueueTriggerToBlob"); string id = Guid.NewGuid().ToString(); string messageContent = string.Format("{{ \"id\": \"{0}\" }}", id); CloudQueueMessage message = new CloudQueueMessage(messageContent); await Fixture.TestQueue.AddMessageAsync(message); var resultBlob = Fixture.TestOutputContainer.GetBlockBlobReference(id); string result = await TestHelpers.WaitForBlobAndGetStringAsync(resultBlob); Assert.Equal(TestHelpers.RemoveByteOrderMarkAndWhitespace(messageContent), TestHelpers.RemoveByteOrderMarkAndWhitespace(result)); string userCategory = LogCategories.CreateFunctionUserCategory("QueueTriggerToBlob"); LogMessage traceEvent = await WaitForTraceAsync(p => p?.FormattedMessage != null && p.FormattedMessage.Contains(id) && string.Equals(p.Category, userCategory, StringComparison.Ordinal)); Assert.Equal(LogLevel.Information, traceEvent.Level); string trace = traceEvent.FormattedMessage; Assert.Contains("script processed queue message", trace); Assert.Contains(messageContent.Replace(" ", string.Empty), trace.Replace(" ", string.Empty)); }
public async Task HttpTrigger_CustomRoute_Post_ReturnsExpectedResponse() { TestHelpers.ClearFunctionLogs("HttpTrigger-CustomRoute-Post"); string id = Guid.NewGuid().ToString(); string functionKey = "5u3pyihh8ldfelipm3qdabw69iah0oghgzw8n959"; string uri = $"api/node/products/housewares/{id}?code={functionKey}"; JObject product = new JObject { { "id", id }, { "name", "Waffle Maker Pro" }, { "category", "Housewares" } }; HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, uri) { Content = new StringContent(product.ToString()) }; HttpResponseMessage response = await this._fixture.HttpClient.SendAsync(request); Assert.Equal(HttpStatusCode.Created, response.StatusCode); // wait for function to execute and produce its result blob CloudBlobContainer outputContainer = _fixture.BlobClient.GetContainerReference("samples-output"); string path = $"housewares/{id}"; CloudBlockBlob outputBlob = outputContainer.GetBlockBlobReference(path); string result = await TestHelpers.WaitForBlobAndGetStringAsync(outputBlob); JObject resultProduct = JObject.Parse(Utility.RemoveUtf8ByteOrderMark(result)); Assert.Equal(id, (string)resultProduct["id"]); Assert.Equal((string)product["name"], (string)resultProduct["name"]); }
public async Task EventHub() { // Event Hub needs the following environment vars: // "AzureWebJobsEventHubSender" - the connection string for the send rule // "AzureWebJobsEventHubReceiver" - the connection string for the receiver rule // "AzureWebJobsEventHubPath" - the path // Test both sending and receiving from an EventHub. // First, manually invoke a function that has an output binding to send EventDatas to an EventHub. // This tests the ability to queue eventhhubs string testData = Guid.NewGuid().ToString(); Dictionary <string, object> arguments = new Dictionary <string, object> { { "input", testData } }; await Fixture.Host.CallAsync("EventHubSender", arguments); // Second, there's an EventHub trigger listener on the events which will write a blob. // Once the blob is written, we know both sender & listener are working. var resultBlob = Fixture.TestOutputContainer.GetBlockBlobReference(testData); string result = await TestHelpers.WaitForBlobAndGetStringAsync(resultBlob); var payload = JsonConvert.DeserializeObject <Payload>(result); Assert.Equal(testData, payload.Id); }
public async Task HttpTriggerToBlob() { var request = new HttpRequestMessage { RequestUri = new Uri($"http://localhost/api/HttpTriggerToBlob?Suffix=TestSuffix"), Method = HttpMethod.Post, }; request.SetConfiguration(Fixture.RequestConfiguration); request.Headers.Add("Prefix", "TestPrefix"); request.Headers.Add("Value", "TestValue"); var id = Guid.NewGuid().ToString(); var metadata = new JObject() { { "M1", "AAA" }, { "M2", "BBB" } }; var input = new JObject() { { "Id", id }, { "Value", "TestInput" }, { "Metadata", metadata } }; request.Content = new StringContent(input.ToString()); request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("text/plain")); var arguments = new Dictionary <string, object> { { "input", request }, { ScriptConstants.SystemTriggerParameterName, request } }; await Fixture.Host.CallAsync("HttpTriggerToBlob", arguments); HttpResponseMessage response = (HttpResponseMessage)request.Properties[ScriptConstants.AzureFunctionsHttpResponseKey]; Assert.Equal(HttpStatusCode.OK, response.StatusCode); string body = await response.Content.ReadAsStringAsync(); string expectedValue = $"TestInput{id}TestValue"; Assert.Equal(expectedValue, body); // verify blob was written string blobName = $"TestPrefix-{id}-TestSuffix-BBB"; var outBlob = Fixture.TestOutputContainer.GetBlockBlobReference(blobName); string result = await TestHelpers.WaitForBlobAndGetStringAsync(outBlob); Assert.Equal(expectedValue, Utility.RemoveUtf8ByteOrderMark(result)); }
public async Task ServiceBusTopicTrigger_Succeeds() { string topicName = "samples-topic"; string subscriptionName = "samples"; string connectionString = AmbientConnectionStringProvider.Instance.GetConnectionString(ConnectionStringNames.ServiceBus); var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString); if (!namespaceManager.TopicExists(topicName)) { namespaceManager.CreateTopic(topicName); } if (!namespaceManager.SubscriptionExists(topicName, subscriptionName)) { namespaceManager.CreateSubscription(topicName, subscriptionName); } var client = Microsoft.ServiceBus.Messaging.TopicClient.CreateFromConnectionString(connectionString, topicName); // write a start message to the queue to kick off the processing string id = Guid.NewGuid().ToString(); string value = Guid.NewGuid().ToString(); JObject message = new JObject { { "id", id }, { "value", value } }; using (Stream stream = new MemoryStream()) using (TextWriter writer = new StreamWriter(stream)) { writer.Write(message.ToString()); writer.Flush(); stream.Position = 0; client.Send(new BrokeredMessage(stream) { ContentType = "text/plain" }); } client.Close(); // wait for function to execute and produce its result blob CloudBlobContainer outputContainer = _fixture.BlobClient.GetContainerReference("samples-output"); CloudBlockBlob outputBlob = outputContainer.GetBlockBlobReference(id); string result = await TestHelpers.WaitForBlobAndGetStringAsync(outputBlob); Assert.Equal(value, result.Trim()); }
public async Task ServiceBusTopicTrigger_ManualInvoke_Succeeds() { string topicName = "samples-topic"; string subscriptionName = "samples"; string connectionString = AmbientConnectionStringProvider.Instance.GetConnectionString(ConnectionStringNames.ServiceBus); var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString); if (!namespaceManager.TopicExists(topicName)) { namespaceManager.CreateTopic(topicName); } if (!namespaceManager.SubscriptionExists(topicName, subscriptionName)) { namespaceManager.CreateSubscription(topicName, subscriptionName); } string uri = "admin/functions/servicebustopictrigger"; HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, uri); request.Headers.Add("x-functions-key", "t8laajal0a1ajkgzoqlfv5gxr4ebhqozebw4qzdy"); string id = Guid.NewGuid().ToString(); string value = Guid.NewGuid().ToString(); JObject input = new JObject() { { "input", new JObject() { { "id", id }, { "value", value } }.ToString() } }; string json = input.ToString(); request.Content = new StringContent(json); request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = await this._fixture.HttpClient.SendAsync(request); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); var client = Microsoft.ServiceBus.Messaging.TopicClient.CreateFromConnectionString(connectionString, topicName); // wait for function to execute and produce its result blob CloudBlobContainer outputContainer = _fixture.BlobClient.GetContainerReference("samples-output"); CloudBlockBlob outputBlob = outputContainer.GetBlockBlobReference(id); string result = await TestHelpers.WaitForBlobAndGetStringAsync(outputBlob); Assert.Equal(value, result.Trim()); }
public async Task HttpTriggerToBlob() { var headers = new HeaderDictionary { { "Prefix", "TestPrefix" }, { "Value", "TestValue" }, { "Content-Type", "application/json" }, { "Accept", "text/plain" } }; var id = Guid.NewGuid().ToString(); var metadata = new JObject() { { "M1", "AAA" }, { "M2", "BBB" } }; var input = new JObject() { { "Id", id }, { "Value", "TestInput" }, { "Metadata", metadata } }; var request = HttpTestHelpers.CreateHttpRequest("POST", "http://localhost/api/HttpTriggerToBlob?Suffix=TestSuffix", headers, input.ToString()); var arguments = new Dictionary <string, object> { { "input", request }, { ScriptConstants.SystemTriggerParameterName, request } }; await Fixture.Host.CallAsync("HttpTriggerToBlob", arguments); var response = (IActionResult)request.HttpContext.Items[ScriptConstants.AzureFunctionsHttpResponseKey]; //Assert.Equal(HttpStatusCode.OK, response.StatusCode); //string body = await response.Content.ReadAsStringAsync(); string expectedValue = $"TestInput{id}TestValue"; //Assert.Equal(expectedValue, body); // verify blob was written string blobName = $"TestPrefix-{id}-TestSuffix-BBB"; var outBlob = Fixture.TestOutputContainer.GetBlockBlobReference(blobName); string result = await TestHelpers.WaitForBlobAndGetStringAsync(outBlob); Assert.Equal(expectedValue, Utility.RemoveUtf8ByteOrderMark(result)); }
public async Task HttpTrigger_CSharp_Poco_Get_Succeeds() { string id = Guid.NewGuid().ToString(); string uri = string.Format("api/httptrigger-csharp-poco?code=zlnu496ve212kk1p84ncrtdvmtpembduqp25ajjc&Id={0}&Value=Testing", id); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, uri); HttpResponseMessage response = await this._fixture.HttpClient.SendAsync(request); Assert.Equal(HttpStatusCode.OK, response.StatusCode); // wait for function to execute and produce its result blob CloudBlobContainer outputContainer = _fixture.BlobClient.GetContainerReference("samples-output"); CloudBlockBlob outputBlob = outputContainer.GetBlockBlobReference(id); string result = await TestHelpers.WaitForBlobAndGetStringAsync(outputBlob); Assert.Equal("Testing", TestHelpers.RemoveByteOrderMarkAndWhitespace(result)); }
public async Task BlobTriggerBatch_Succeeds() { // write input blob CloudBlobContainer inputContainer = _fixture.BlobClient.GetContainerReference("samples-batch"); string blobName = Guid.NewGuid().ToString(); string testData = "This is a test"; CloudBlockBlob inputBlob = inputContainer.GetBlockBlobReference(blobName); await inputBlob.UploadTextAsync(testData); // wait for function to execute and produce its result blob CloudBlobContainer outputContainer = _fixture.BlobClient.GetContainerReference("samples-output"); CloudBlockBlob outputBlob = outputContainer.GetBlockBlobReference(blobName); string result = await TestHelpers.WaitForBlobAndGetStringAsync(outputBlob); // verify results Assert.Equal(testData, result.Trim()); }
protected async Task ApiHubTest() { // ApiHub for dropbox is enabled if the AzureWebJobsDropBox environment variable is set. // The format should be: Endpoint={endpoint};Scheme={scheme};AccessToken={accesstoken} // or to use the local file system the format should be: UseLocalFileSystem=true;Path={path} string apiHubConnectionString = Environment.GetEnvironmentVariable("AzureWebJobsDropBox"); if (string.IsNullOrEmpty(apiHubConnectionString)) { throw new ApplicationException("Missing AzureWebJobsDropBox environment variable."); } string testBlob = "teste2e"; string apiHubFile = "teste2e/test.txt"; var resultBlob = Fixture.TestOutputContainer.GetBlockBlobReference(testBlob); resultBlob.DeleteIfExists(); var root = ItemFactory.Parse(apiHubConnectionString); if (root.FileExists(apiHubFile)) { var file = await root.GetFileReferenceAsync(apiHubFile); await file.DeleteAsync(); } // Test both writing and reading from ApiHubFile. // First, manually invoke a function that has an output binding to write to Dropbox. string testData = Guid.NewGuid().ToString(); Dictionary <string, object> arguments = new Dictionary <string, object> { { "input", testData }, }; await Fixture.Host.CallAsync("ApiHubFileSender", arguments); // Second, there's an ApiHubFile trigger which will write a blob. // Once the blob is written, we know both sender & listener are working. // TODO: removing the BOM character from result. string result = (await TestHelpers.WaitForBlobAndGetStringAsync(resultBlob)).Remove(0, 1); Assert.Equal(testData, result); }
public async Task ServiceBusQueueTrigger_Succeeds() { string queueName = "samples-input"; string connectionString = AmbientConnectionStringProvider.Instance.GetConnectionString(ConnectionStringNames.ServiceBus); var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString); namespaceManager.DeleteQueue(queueName); namespaceManager.CreateQueue(queueName); var client = Microsoft.ServiceBus.Messaging.QueueClient.CreateFromConnectionString(connectionString, queueName); // write a start message to the queue to kick off the processing int max = 3; string id = Guid.NewGuid().ToString(); JObject message = new JObject { { "count", 1 }, { "max", max }, { "id", id } }; using (Stream stream = new MemoryStream()) using (TextWriter writer = new StreamWriter(stream)) { writer.Write(message.ToString()); writer.Flush(); stream.Position = 0; client.Send(new BrokeredMessage(stream) { ContentType = "text/plain" }); } client.Close(); // wait for function to execute and produce its result blob CloudBlobContainer outputContainer = _fixture.BlobClient.GetContainerReference("samples-output"); CloudBlockBlob outputBlob = outputContainer.GetBlockBlobReference(id); string result = await TestHelpers.WaitForBlobAndGetStringAsync(outputBlob); Assert.Equal(string.Format("{0} messages processed", max), result.Trim()); }
public async Task HttpTrigger_CSharp_Poco_Post_Xml_Succeeds() { string uri = "api/httptrigger-csharp-poco?code=zlnu496ve212kk1p84ncrtdvmtpembduqp25ajjc"; HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, uri); string id = Guid.NewGuid().ToString(); request.Content = new StringContent(string.Format("<RequestData xmlns=\"http://functions\"><Id>{0}</Id><Value>Testing</Value></RequestData>", id)); request.Content.Headers.ContentType = new MediaTypeHeaderValue("text/xml"); HttpResponseMessage response = await this._fixture.HttpClient.SendAsync(request); Assert.Equal(HttpStatusCode.OK, response.StatusCode); // wait for function to execute and produce its result blob CloudBlobContainer outputContainer = _fixture.BlobClient.GetContainerReference("samples-output"); CloudBlockBlob outputBlob = outputContainer.GetBlockBlobReference(id); string result = await TestHelpers.WaitForBlobAndGetStringAsync(outputBlob); Assert.Equal("Testing", TestHelpers.RemoveByteOrderMarkAndWhitespace(result)); }
public async Task ManualTrigger_Invoke_Succeeds() { CloudBlobContainer outputContainer = _fixture.BlobClient.GetContainerReference("samples-output"); string inId = Guid.NewGuid().ToString(); string outId = Guid.NewGuid().ToString(); CloudBlockBlob statusBlob = outputContainer.GetBlockBlobReference(inId); JObject testData = new JObject() { { "first", "Mathew" }, { "last", "Charles" } }; statusBlob.UploadText(testData.ToString(Formatting.None)); string uri = "admin/functions/manualtrigger"; HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, uri); request.Headers.Add("x-functions-key", "t8laajal0a1ajkgzoqlfv5gxr4ebhqozebw4qzdy"); JObject input = new JObject() { { "input", new JObject() { { "inId", inId }, { "outId", outId } }.ToString() } }; string json = input.ToString(); request.Content = new StringContent(json); request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = await this._fixture.HttpClient.SendAsync(request); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); // wait for completion CloudBlockBlob outputBlob = outputContainer.GetBlockBlobReference(outId); string result = await TestHelpers.WaitForBlobAndGetStringAsync(outputBlob); Assert.Equal("Mathew Charles", result); }
public async Task QueueTriggerPython_Succeeds() { TestHelpers.ClearFunctionLogs("QueueTrigger-Python"); // write the input message CloudQueue inputQueue = _fixture.QueueClient.GetQueueReference("samples-python"); inputQueue.CreateIfNotExists(); string id = Guid.NewGuid().ToString(); JObject jsonObject = new JObject { { "id", id } }; var message = new CloudQueueMessage(jsonObject.ToString(Formatting.None)); await inputQueue.AddMessageAsync(message); // wait for function to execute and produce its result blob CloudBlobContainer outputContainer = _fixture.BlobClient.GetContainerReference("samples-output"); CloudBlockBlob outputBlob = outputContainer.GetBlockBlobReference(id); string result = await TestHelpers.WaitForBlobAndGetStringAsync(outputBlob); jsonObject = JObject.Parse(result); Assert.Equal(id, (string)jsonObject["id"]); // verify the function output var logs = await TestHelpers.GetFunctionLogsAsync("QueueTrigger-Python"); // strip off the timestamps from the beginning of each line logs = logs.Select(l => l.Split(new[] { ' ' }, 2)[1]).ToList(); int idx = logs.IndexOf("Read 5 Table entities"); for (int i = idx + 1; i < 5; i++) { string json = logs[i]; JObject entity = JObject.Parse(json); Assert.Equal("samples-python", entity["PartitionKey"]); Assert.Equal(0, (int)entity["Status"]); } }
protected async Task CosmosDBTriggerToBlobTestImpl() { // DocumentDB tests need the following environment vars: // "AzureWebJobsDocumentDBConnectionString" -- the connection string to the account // Waiting for the Processor to adquire leases await Task.Delay(10000); await Fixture.InitializeDocumentClient(); bool collectionsCreated = await Fixture.CreateDocumentCollections(); var resultBlob = Fixture.TestOutputContainer.GetBlockBlobReference("cosmosdbtriggere2e-completed"); await resultBlob.DeleteIfExistsAsync(); string id = Guid.NewGuid().ToString(); Document documentToTest = new Document() { Id = id }; await Fixture.DocumentClient.CreateDocumentAsync(UriFactory.CreateDocumentCollectionUri("ItemDb", "ItemCollection"), documentToTest); // wait for logs to flush await Task.Delay(FileTraceWriter.LogFlushIntervalMs); // now wait for function to be invoked string result = await TestHelpers.WaitForBlobAndGetStringAsync(resultBlob); if (collectionsCreated) { // cleanup collections await Fixture.DeleteDocumentCollections(); } Assert.Equal(TestHelpers.RemoveByteOrderMarkAndWhitespace(id), TestHelpers.RemoveByteOrderMarkAndWhitespace(result)); }
public async Task QueueTriggerBatch_Succeeds() { // write the input message CloudQueue inputQueue = _fixture.QueueClient.GetQueueReference("samples-batch"); inputQueue.CreateIfNotExists(); string id = Guid.NewGuid().ToString(); JObject jsonObject = new JObject { { "id", id } }; var message = new CloudQueueMessage(jsonObject.ToString(Formatting.None)); await inputQueue.AddMessageAsync(message); // wait for function to execute and produce its result blob CloudBlobContainer outputContainer = _fixture.BlobClient.GetContainerReference("samples-output"); CloudBlockBlob outputBlob = outputContainer.GetBlockBlobReference(id); string result = await TestHelpers.WaitForBlobAndGetStringAsync(outputBlob); jsonObject = JObject.Parse(result); Assert.Equal(id, (string)jsonObject["id"]); }
public async Task BlobTriggerBatch_Succeeds() { // write input blob CloudBlobContainer inputContainer = _fixture.BlobClient.GetContainerReference("samples-batch"); await inputContainer.CreateIfNotExistsAsync(); // Processing a large number of blobs on startup can take a while, // so let's start with an empty container. TestHelpers.ClearContainer(inputContainer); string blobName = Guid.NewGuid().ToString(); string testData = "This is a test"; CloudBlockBlob inputBlob = inputContainer.GetBlockBlobReference(blobName); await inputBlob.UploadTextAsync(testData); // wait for function to execute and produce its result blob CloudBlobContainer outputContainer = _fixture.BlobClient.GetContainerReference("samples-output"); CloudBlockBlob outputBlob = outputContainer.GetBlockBlobReference(blobName); string result = await TestHelpers.WaitForBlobAndGetStringAsync(outputBlob); // verify results Assert.Equal(testData, result.Trim()); }
public async Task QueueTriggerToBlobTest() { TestHelpers.ClearFunctionLogs("QueueTriggerToBlob"); string id = Guid.NewGuid().ToString(); string messageContent = string.Format("{{ \"id\": \"{0}\" }}", id); CloudQueueMessage message = new CloudQueueMessage(messageContent); await Fixture.TestQueue.AddMessageAsync(message); var resultBlob = Fixture.TestOutputContainer.GetBlockBlobReference(id); string result = await TestHelpers.WaitForBlobAndGetStringAsync(resultBlob); Assert.Equal(TestHelpers.RemoveByteOrderMarkAndWhitespace(messageContent), TestHelpers.RemoveByteOrderMarkAndWhitespace(result)); TraceEvent traceEvent = await WaitForTraceAsync(p => p.Message.Contains(id)); Assert.Equal(TraceLevel.Info, traceEvent.Level); string trace = traceEvent.Message; Assert.True(trace.Contains("script processed queue message")); Assert.True(trace.Replace(" ", string.Empty).Contains(messageContent.Replace(" ", string.Empty))); }