Ejemplo n.º 1
0
        /// <summary>
        /// The <see cref="CreateShare(string, ShareCreateOptions, CancellationToken)"/>
        /// operation creates a new share under the specified account. If a share with the same name
        /// already exists, the operation fails.
        ///
        /// For more information, see
        /// <see href="https://docs.microsoft.com/rest/api/storageservices/create-share">
        /// Create Share</see>.
        /// </summary>
        /// <param name="shareName">
        /// The name of the share to create.
        /// </param>
        /// <param name="options">
        /// Optional parameters.
        /// </param>
        /// <param name="cancellationToken">
        /// Optional <see cref="CancellationToken"/> to propagate
        /// notifications that the operation should be cancelled.
        /// </param>
        /// <returns>
        /// A <see cref="Response{ShareClient}"/> referencing the newly
        /// created share.
        /// </returns>
        /// <remarks>
        /// A <see cref="RequestFailedException"/> will be thrown if
        /// a failure occurs.
        /// </remarks>
        public virtual async Task <Response <ShareClient> > CreateShareAsync(
            string shareName,
            ShareCreateOptions options,
            CancellationToken cancellationToken = default)
        {
            ShareClient share = GetShareClient(shareName);

            Response <ShareInfo> response = await share.CreateInternal(
                options?.Metadata,
                options?.QuotaInGB,
                options?.AccessTier,
                async : true,
                cancellationToken,
                operationName : $"{nameof(ShareServiceClient)}.{nameof(CreateShare)}")
                                            .ConfigureAwait(false);

            return(Response.FromValue(share, response.GetRawResponse()));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The <see cref="CreateShare(string, ShareCreateOptions, CancellationToken)"/>
        /// operation creates a new share under the specified account. If a share with the same name
        /// already exists, the operation fails.
        ///
        /// For more information, see
        /// <see href="https://docs.microsoft.com/rest/api/storageservices/create-share">
        /// Create Share</see>.
        /// </summary>
        /// <param name="shareName">
        /// The name of the share to create.
        /// </param>
        /// <param name="options">
        /// Optional parameters.
        /// </param>
        /// <param name="cancellationToken">
        /// Optional <see cref="CancellationToken"/> to propagate
        /// notifications that the operation should be cancelled.
        /// </param>
        /// <returns>
        /// A <see cref="Response{ShareClient}"/> referencing the newly
        /// created share.
        /// </returns>
        /// <remarks>
        /// A <see cref="RequestFailedException"/> will be thrown if
        /// a failure occurs.
        /// </remarks>
        public virtual Response <ShareClient> CreateShare(
            string shareName,
            ShareCreateOptions options,
            CancellationToken cancellationToken = default)
        {
            ShareClient share = GetShareClient(shareName);

            Response <ShareInfo> response = share.CreateInternal(
                options?.Metadata,
                options?.QuotaInGB,
                options?.AccessTier,
                async: false,
                cancellationToken,
                operationName: $"{nameof(ShareServiceClient)}.{nameof(CreateShare)}")
                                            .EnsureCompleted();

            return(Response.FromValue(share, response.GetRawResponse()));
        }