Ejemplo n.º 1
0
        public static async Task <MediaTableEntity> RunAsync(
            [QueueTrigger("media-request", Connection = "AzureWebJobsStorage")] string media,
            ILogger log
            )
        {
            var entity = JsonConvert.DeserializeObject <MediaEntity>(media);

            entity = await ProcessMediaAsync(entity);

            var tableEntity = new MediaTableEntity(entity)
            {
                // This must be set to allow upsert entity
                ETag = "*",
            };

            return(await Task.FromResult(tableEntity));
        }
Ejemplo n.º 2
0
        public async Task <string> CreateWithTokenAsync(MediaEntity entity)
        {
            var tableEntity = new MediaTableEntity(entity);
            await Table.ExecuteAsync(TableOperation.Insert(tableEntity));

            var policy = new SharedAccessTablePolicy()
            {
                Permissions            = SharedAccessTablePermissions.Query,
                SharedAccessStartTime  = DateTimeOffset.UtcNow,
                SharedAccessExpiryTime = DateTimeOffset.UtcNow.AddHours(1),
            };
            var token = Table.GetSharedAccessSignature(
                policy, null,
                tableEntity.PartitionKey, string.Empty,
                tableEntity.PartitionKey, Constants.TableStorageLexicalMaxValue);
            var storageUrl = StorageAccount.TableStorageUri.PrimaryUri.ToString().TrimEnd('/');
            var tokenUrl   = $"{storageUrl}/{Table.Name}{token}";

            return(tokenUrl);
        }