예제 #1
0
        public async Task <string> GetPolicyLookupPath(string subscriptionId, string policyName)
        {
            var table = await TableUtil.GetTableReference(Tables.PolicyLookupPaths);

            var retrieveOperation = TableOperation.Retrieve <PolicyLookupPathEntity>(subscriptionId, policyName);
            var tableResult       = await table.ExecuteAsync(retrieveOperation);

            return((tableResult.Result as PolicyLookupPathEntity)?.PolicyLookupPath);
        }
예제 #2
0
        public async Task <List <PolicyLookupPathEntity> > GetPolicyLookupPaths(string subscriptionId)
        {
            var table = await TableUtil.GetTableReference(Tables.PolicyLookupPaths);

            TableQuery <PolicyLookupPathEntity> query = new TableQuery <PolicyLookupPathEntity>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, subscriptionId));
            var result = table.ExecuteQuery(query).ToList();

            return(result);
        }
예제 #3
0
        internal static async Task DeleteTableItem <T>(T item, string tableName) where T : TableEntity
        {
            item.PartitionKey = item.PartitionKey ?? "Admin";
            item.ETag         = "*";
            var table = await TableUtil.GetTableReference(tableName);

            var deleteOperation = TableOperation.Delete(item);
            await table.ExecuteAsync(deleteOperation);
        }
예제 #4
0
        internal static async Task <T> SaveTableItem <T>(T item, string tableName) where T : TableEntity
        {
            var table = await TableUtil.GetTableReference(tableName);

            var saveOperation = TableOperation.InsertOrReplace(item);
            var tableResult   = await table.ExecuteAsync(saveOperation);

            return((T)tableResult.Result);
        }
예제 #5
0
        /// <summary>
        /// This implementation uses Wintellect Azure Table library to overcome the limitation of 32KB for string attributes.
        /// The ARM template data is now stored as bytes and Wintellect library is used to automatically split and join the byte array based on pre-defined number of splits.
        /// Refer <see cref="TemplateEntity"/> for implementation details
        /// </summary>
        public async Task <TemplateViewModel> GetTemplate(string templateName)
        {
            var table = await TableUtil.GetTableReference(Tables.Products);

            var azTable = new AzureTable(table);

            var dynamicTemplateEntity = await TemplateEntity.FindAsync(azTable, partitionKey, templateName);

            var templateViewModel = new TemplateEntity(azTable, dynamicTemplateEntity);

            return(TemplateEntity.MapToViewModel(templateViewModel));
        }
예제 #6
0
        /// <summary>
        /// This implementation uses Wintellect Azure Table library to overcome the limitation of 32KB for string attributes.
        /// The ARM template data is now stored as bytes and Wintellect library is used to automatically split and join the byte array based on pre-defined number of splits.
        /// Refer <see cref="TemplateEntity"/> for implementation details
        /// </summary>
        public async Task DeleteTemplate(string rowKey)
        {
            var table = await TableUtil.GetTableReference(Tables.Products);

            var azTable = new AzureTable(table);

            var templateEntity = new TemplateEntity(azTable);

            templateEntity.RowKey       = rowKey;
            templateEntity.PartitionKey = partitionKey;
            templateEntity.ETag         = "*";

            await templateEntity.DeleteAsync();
        }
예제 #7
0
        /// <summary>
        /// This implementation uses Wintellect Azure Table library to overcome the limitation of 32KB for string attributes.
        /// The ARM template data is now stored as bytes and Wintellect library is used to automatically split and join the byte array based on pre-defined number of splits.
        /// Refer <see cref="TemplateEntity"/> for implementation details
        /// </summary>
        public async Task <TemplateViewModel> SaveTemplate(TemplateViewModel template)
        {
            template.PartitionKey     = partitionKey;
            template.ProductImagePath = await SaveProductImageAsBlob(template.ProductImage);

            template.ProductImage = null; //Null out the base64 data

            var table = await TableUtil.GetTableReference(Tables.Products);

            var azTable = new AzureTable(table);

            var templateEntity = TemplateEntity.MapFromViewModel(template, azTable);

            var tableResult = await templateEntity.InsertOrReplaceAsync();

            var templateViewModel = TemplateEntity.MapToViewModel((TemplateEntity)tableResult.Result);

            return(templateViewModel);
        }
예제 #8
0
        /// <summary>
        /// This implementation uses Wintellect Azure Table library to overcome the limitation of 32KB for string attributes.
        /// The ARM template data is now stored as bytes and Wintellect library is used to automatically split and join the byte array based on pre-defined number of splits.
        /// Refer <see cref="TemplateEntity"/> for implementation details
        /// </summary>
        public async Task <List <TemplateViewModel> > GetTemplates()
        {
            var query = new TableQuery();

            query.FilterString = new TableFilterBuilder <TemplateEntity>()
                                 .And(te => te.PartitionKey, CompareOp.EQ, partitionKey);

            var table = await TableUtil.GetTableReference(Tables.Products);

            var azTable = new AzureTable(table);

            var dynamicTemplateEntities = table.ExecuteQuery(query);
            var templateList            = new List <TemplateViewModel>();

            foreach (var entity in dynamicTemplateEntities)
            {
                var templateEntity = new TemplateEntity(azTable, entity);
                templateList.Add(TemplateEntity.MapToViewModel(templateEntity));
            }

            return(templateList);
        }