public virtual Response <ShareClient> CreateShare( string shareName, IDictionary <string, string> metadata = default, int?quotaInGB = default, CancellationToken cancellationToken = default) { ShareClient share = GetShareClient(shareName); Response <ShareInfo> response = share.CreateInternal( metadata, quotaInGB, accessTier: default,
/// <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())); }
/// <summary> /// The <see cref="CreateShareAsync"/> 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="metadata"> /// Optional custom metadata to set for this share. /// </param> /// <param name="quotaInGB"> /// Optional. Maximum size of the share in bytes. If unspecified, use the service's default value. /// </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, IDictionary <string, string> metadata = default, int?quotaInGB = default, CancellationToken cancellationToken = default) { ShareClient share = GetShareClient(shareName); Response <ShareInfo> response = await share.CreateInternal( metadata, quotaInGB, async : true, cancellationToken, operationName : $"{nameof(ShareServiceClient)}.{nameof(CreateShare)}") .ConfigureAwait(false); return(Response.FromValue(share, response.GetRawResponse())); }
/// <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())); }
/// <summary> /// The <see cref="CreateShare"/> 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="metadata"> /// Optional custom metadata to set for this share. /// </param> /// <param name="quotaInGB"> /// Optional. Maximum size of the share in bytes. If unspecified, use the service's default value. /// </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, IDictionary <string, string> metadata = default, int?quotaInGB = default, CancellationToken cancellationToken = default) { ShareClient share = GetShareClient(shareName); Response <ShareInfo> response = share.CreateInternal( metadata, quotaInGB, async: false, cancellationToken, operationName: $"{nameof(ShareServiceClient)}.{nameof(CreateShare)}") .EnsureCompleted(); return(Response.FromValue(share, response.GetRawResponse())); }