Пример #1
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage req, ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            // Obtain ConnectionString from KeyVault
            var connectionString = await KeyVaultHelper.GetSecretValueAsync(AppSettings.EnvKeyVaultTableStorageConnectionString);

            // TableReference
            var table  = CloudStoreageAccountHelper.GetTableReference(connectionString, AppSettings.EnvTableStorageTableName);
            var entity = await table.RetrieveAsync <AssetEntity>(AppSettings.EnvTableStorageTableDefaultPartition, AppSettings.EnvTableStorageTableDefaultAssetName);

            log.LogInformation($"{entity.PartitionKey}\t{entity.RowKey}\t{entity.Timestamp}\t{entity.AssetName}");
            return(req.CreateResponse(HttpStatusCode.OK, entity.AssetName));
        }
Пример #2
0
        private static async Task <string> GetBlobNameAsync(string partition, string key)
        {
            // Obtain ConnectionString from KeyVault
            var connectionString = await KeyVaultHelper.GetSecretValueAsync(AppSettings.EnvKeyVaultTableStorageConnectionString);

            // TableReference
            var table = CloudStoreageAccountHelper.GetTableReference(connectionString, AppSettings.EnvTableStorageTableName);

            if (string.IsNullOrWhiteSpace(partition))
            {
                partition = AppSettings.EnvTableStorageTableDefaultPartition;
            }
            if (string.IsNullOrWhiteSpace(key))
            {
                key = AppSettings.EnvTableStorageTableDefaultAssetName;
            }

            var entity = await table.RetrieveAsync <AssetEntity>(partition, key);

            return(entity.AssetName);
        }