/// <summary>
        /// Creates a table on the service.
        /// </summary>
        /// <param name="tableName">The name of table to create.</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
        /// <returns>A <see cref="Response{TableItem}"/> containing properties of the table.</returns>
        public virtual async Task <Response <TableItem> > CreateTableAsync(string tableName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(tableName, nameof(tableName));
            using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(CreateTable)}");
            scope.Start();
            try
            {
                var response = await _tableOperations.CreateAsync(
                    new TableProperties()
                {
                    TableName = tableName
                },
                    null,
                    queryOptions : _defaultQueryOptions,
                    cancellationToken : cancellationToken)
                               .ConfigureAwait(false);

                return(Response.FromValue(response.Value as TableItem, response.GetRawResponse()));
            }
            catch (Exception ex)
            {
                scope.Failed(ex);
                throw;
            }
        }
Esempio n. 2
0
        public virtual async Task <Response <TableItem> > CreateAsync(CancellationToken cancellationToken = default)
        {
            var response = await _tableOperations.CreateAsync(new TableProperties(_table), null, queryOptions : new QueryOptions()
            {
                Format = _format
            }, cancellationToken : cancellationToken).ConfigureAwait(false);

            return(Response.FromValue(response.Value as TableItem, response.GetRawResponse()));
        }
Esempio n. 3
0
        public virtual async Task <Response <TableItem> > CreateTableAsync(string tableName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(tableName, nameof(tableName));

            var response = await _tableOperations.CreateAsync(new TableProperties(tableName), null, queryOptions : new QueryOptions {
                Format = _format
            }, cancellationToken : cancellationToken).ConfigureAwait(false);

            return(Response.FromValue(response.Value as TableItem, response.GetRawResponse()));
        }