public static async Task <HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "v1/azuresearch/performance/blobstorage/serially/narrow/repetitions/{repetitions}")] HttpRequestMessage req, int repetitions, ExecutionContext executionContext, ILogger log) { List <string> ids = Common.IdsList; DateTime startTime = DateTime.Now; StorageCredentials storageCredentials = new StorageCredentials( Environment.GetEnvironmentVariable("storageAccountName", EnvironmentVariableTarget.Process), Environment.GetEnvironmentVariable("storageAccountKey", EnvironmentVariableTarget.Process)); CloudStorageAccount cloudStorageAccount = new CloudStorageAccount(storageCredentials, useHttps: true); CloudBlobClient blobClient = cloudStorageAccount.CreateCloudBlobClient(); CloudBlobContainer cloudBlobContainer = blobClient.GetContainerReference("transformed"); List <ProviderNarrow> providers = new List <ProviderNarrow>(ids.Count); for (int r = 0; r < repetitions; r++) { foreach (string id in ids) { CloudBlockBlob cloudBlockBlob = cloudBlobContainer.GetBlockBlobReference($"ky-2019-04-25-16-00-00-0387-Utc/{id}.json"); string doc = await cloudBlockBlob.DownloadTextAsync(); ProviderNarrow p = JsonConvert.DeserializeObject <ProviderNarrow>(doc); providers.Add(p); } } return(req.CreateResponse( HttpStatusCode.OK, $"{repetitions} repetitions in {nameof(BlobStorageSerial)}->{executionContext.FunctionName}(): {(DateTime.Now - startTime).TotalMilliseconds}, per repetition {(DateTime.Now - startTime).TotalMilliseconds / repetitions}")); }
public static HttpResponseMessage Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "v1/azuresearch/performance/blobstorage/serially/narrow/repetitions/{repetitions}")] HttpRequestMessage req, int repetitions, ExecutionContext executionContext, TraceWriter log) { List <string> ids = Common.IdsList; DateTime startTime = DateTime.Now; StorageCredentials storageCredentials = new StorageCredentials(CloudConfigurationManager.GetSetting("storageAccountName"), CloudConfigurationManager.GetSetting("storageAccountKey")); CloudStorageAccount cloudStorageAccount = new CloudStorageAccount(storageCredentials, useHttps: true); CloudBlobClient blobClient = cloudStorageAccount.CreateCloudBlobClient(); CloudBlobContainer cloudBlobContainer = blobClient.GetContainerReference("transformed"); List <ProviderNarrow> providers = new List <ProviderNarrow>(ids.Count); for (int r = 0; r < repetitions; r++) { foreach (string id in ids) { CloudBlockBlob cloudBlockBlob = cloudBlobContainer.GetBlockBlobReference($"k-2018-11-20-21-48-47-0857-Utc/{id}.json"); string doc = cloudBlockBlob.DownloadText(); ProviderNarrow p = JsonConvert.DeserializeObject <ProviderNarrow>(doc); providers.Add(p); } } return(req.CreateResponse( HttpStatusCode.OK, $"{repetitions} repetitions in {nameof(BlobStorageSerial)}->{executionContext.FunctionName}(): {(DateTime.Now - startTime).TotalMilliseconds}, per repetition {(DateTime.Now - startTime).TotalMilliseconds / repetitions}")); }