public virtual Response Create()

in sdk/storage/Azure.Storage.Files.Shares/src/ShareClient.cs [486:799]


        public virtual Response<ShareInfo> Create(
            ShareCreateOptions options,
            CancellationToken cancellationToken = default) =>
            CreateInternal(
                options?.Metadata,
                options?.QuotaInGB,
                options?.AccessTier,
                options?.Protocols,
                options?.RootSquash,
                options?.EnableSnapshotVirtualDirectoryAccess,
                options?.EnablePaidBursting,
                options?.PaidBurstingMaxIops,
                options?.PaidBurstingMaxBandwidthMibps,
                options?.ProvisionedMaxIops,
                options?.ProvisionedMaxBandwidthMibps,
                async: false,
                cancellationToken)
                .EnsureCompleted();

        /// <summary>
        /// The <see cref="CreateAsync(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="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{ShareInfo}"/> describing the newly
        /// created share.
        /// </returns>
        /// <remarks>
        /// A <see cref="RequestFailedException"/> will be thrown if
        /// a failure occurs.
        /// If multiple failures occur, an <see cref="AggregateException"/> will be thrown,
        /// containing each failure instance.
        /// </remarks>
        public virtual async Task<Response<ShareInfo>> CreateAsync(
            ShareCreateOptions options,
            CancellationToken cancellationToken = default) =>
            await CreateInternal(
                options?.Metadata,
                options?.QuotaInGB,
                options?.AccessTier,
                options?.Protocols,
                options?.RootSquash,
                options?.EnableSnapshotVirtualDirectoryAccess,
                options?.EnablePaidBursting,
                options?.PaidBurstingMaxIops,
                options?.PaidBurstingMaxBandwidthMibps,
                options?.ProvisionedMaxIops,
                options?.ProvisionedMaxBandwidthMibps,
                async: true,
                cancellationToken)
                .ConfigureAwait(false);

        /// <summary>
        /// The <see cref="Create(Metadata, int?, 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="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{ShareInfo}"/> describing the newly
        /// created share.
        /// </returns>
        /// <remarks>
        /// A <see cref="RequestFailedException"/> will be thrown if
        /// a failure occurs.
        /// If multiple failures occur, an <see cref="AggregateException"/> will be thrown,
        /// containing each failure instance.
        /// </remarks>
        [EditorBrowsable(EditorBrowsableState.Never)]
        public virtual Response<ShareInfo> Create(
            Metadata metadata = default,
            int? quotaInGB = default,
            CancellationToken cancellationToken = default) =>
            CreateInternal(
                metadata,
                quotaInGB,
                accessTier: default,
                enabledProtocols: default,
                rootSquash: default,
                enableSnapshotVirtualDirectoryAccess: default,
                enablePaidBursting: default,
                paidBurstingMaxIops: default,
                paidBurstingMaxBandwidthMibps: default,
                provisionedMaxIops: default,
                provisionedMaxBandwidthMibps: default,
                async: false,
                cancellationToken)
                .EnsureCompleted();

        /// <summary>
        /// The <see cref="CreateAsync(Metadata, int?, 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="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{ShareInfo}"/> describing the newly
        /// created share.
        /// </returns>
        /// <remarks>
        /// A <see cref="RequestFailedException"/> will be thrown if
        /// a failure occurs.
        /// If multiple failures occur, an <see cref="AggregateException"/> will be thrown,
        /// containing each failure instance.
        /// </remarks>
        [EditorBrowsable(EditorBrowsableState.Never)]
        public virtual async Task<Response<ShareInfo>> CreateAsync(
            Metadata metadata = default,
            int? quotaInGB = default,
            CancellationToken cancellationToken = default) =>
            await CreateInternal(
                metadata,
                quotaInGB,
                accessTier: default,
                enabledProtocols: default,
                rootSquash: default,
                enableSnapshotVirtualDirectoryAccess: default,
                enablePaidBursting: default,
                paidBurstingMaxIops: default,
                paidBurstingMaxBandwidthMibps: default,
                provisionedMaxIops: default,
                provisionedMaxBandwidthMibps: default,
                async: true,
                cancellationToken)
                .ConfigureAwait(false);

        /// <summary>
        /// The <see cref="CreateInternal"/> 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="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="accessTier">
        /// Optional.  Specifies the access tier of the share.
        /// </param>
        /// <param name="enabledProtocols">
        /// The protocols to enable on the share.
        /// </param>
        /// <param name="rootSquash">
        /// Squash root to set on the share.
        /// </param>
        /// <param name="enableSnapshotVirtualDirectoryAccess">
        /// Optional. Supported in version 2023-08-03 and above.
        /// Specifies whether the snapshot virtual directory should be accessible at the root of share mount point when NFS is enabled.
        /// If not specified, the default is true.
        /// </param>
        /// <param name="enablePaidBursting">
        ///  Optional. Supported in version 2024-11-04 and above.  Only applicable for premium file storage accounts.
        ///  This property enables paid bursting on premium file storage accounts.
        /// </param>
        /// <param name="paidBurstingMaxIops">
        ///  Optional. Supported in version 2024-11-04 and above.  Only applicable for premium file storage accounts.
        ///  Default if not specified is the maximum IOPS the file share can support. Current maximum for a file share is 102,400 IOPS.
        /// </param>
        /// <param name="paidBurstingMaxBandwidthMibps">
        ///  Optional. Supported in version 2024-11-04 and above.  Only applicable for premium file storage accounts.
        ///  Default if not specified is the maximum throughput the file share can support. Current maximum for a file share is 10,340 MiB/sec.
        /// </param>
        /// <param name="provisionedMaxIops">
        /// Provisioned max IOPS.
        /// </param>
        /// <param name="provisionedMaxBandwidthMibps">
        /// Provisioned max bandwidth MiBps.
        /// </param>
        /// <param name="async">
        /// Whether to invoke the operation asynchronously.
        /// </param>
        /// <param name="cancellationToken">
        /// Optional <see cref="CancellationToken"/> to propagate
        /// notifications that the operation should be cancelled.
        /// </param>
        /// <param name="operationName">
        /// Optional. To indicate if the name of the operation.
        /// </param>
        /// <returns>
        /// A <see cref="Response{ShareInfo}"/> describing the newly
        /// created share.
        /// </returns>
        /// <remarks>
        /// A <see cref="RequestFailedException"/> will be thrown if
        /// a failure occurs.
        /// If multiple failures occur, an <see cref="AggregateException"/> will be thrown,
        /// containing each failure instance.
        /// </remarks>
        internal async Task<Response<ShareInfo>> CreateInternal(
            Metadata metadata,
            int? quotaInGB,
            ShareAccessTier? accessTier,
            ShareProtocols? enabledProtocols,
            ShareRootSquash? rootSquash,
            bool? enableSnapshotVirtualDirectoryAccess,
            bool? enablePaidBursting,
            long? paidBurstingMaxIops,
            long? paidBurstingMaxBandwidthMibps,
            long? provisionedMaxIops,
            long? provisionedMaxBandwidthMibps,
            bool async,
            CancellationToken cancellationToken,
            string operationName = default)
        {
            using (ClientConfiguration.Pipeline.BeginLoggingScope(nameof(ShareClient)))
            {
                ClientConfiguration.Pipeline.LogMethodEnter(
                    nameof(ShareClient),
                    message:
                    $"{nameof(Uri)}: {Uri}\n" +
                    $"{nameof(quotaInGB)}: {quotaInGB}");

                operationName ??= $"{nameof(ShareClient)}.{nameof(Create)}";
                DiagnosticScope scope = ClientConfiguration.ClientDiagnostics.CreateScope(operationName);

                try
                {
                    scope.Start();
                    ResponseWithHeaders<ShareCreateHeaders> response;

                    if (async)
                    {
                        response = await ShareRestClient.CreateAsync(
                            metadata: metadata,
                            quota: quotaInGB,
                            accessTier: accessTier,
                            enabledProtocols: enabledProtocols.ToShareEnableProtocolsString(),
                            rootSquash: rootSquash,
                            enableSnapshotVirtualDirectoryAccess: enableSnapshotVirtualDirectoryAccess,
                            paidBurstingEnabled: enablePaidBursting,
                            paidBurstingMaxIops: paidBurstingMaxIops,
                            paidBurstingMaxBandwidthMibps: paidBurstingMaxBandwidthMibps,
                            shareProvisionedIops: provisionedMaxIops,
                            shareProvisionedBandwidthMibps: provisionedMaxBandwidthMibps,
                            cancellationToken: cancellationToken)
                            .ConfigureAwait(false);
                    }
                    else
                    {
                        response = ShareRestClient.Create(
                            metadata: metadata,
                            quota: quotaInGB,
                            accessTier: accessTier,
                            enabledProtocols: enabledProtocols.ToShareEnableProtocolsString(),
                            rootSquash: rootSquash,
                            enableSnapshotVirtualDirectoryAccess: enableSnapshotVirtualDirectoryAccess,
                            paidBurstingEnabled: enablePaidBursting,
                            paidBurstingMaxIops: paidBurstingMaxIops,
                            paidBurstingMaxBandwidthMibps: paidBurstingMaxBandwidthMibps,
                            shareProvisionedIops: provisionedMaxIops,
                            shareProvisionedBandwidthMibps: provisionedMaxBandwidthMibps,
                            cancellationToken: cancellationToken);
                    }

                    return Response.FromValue(
                        response.ToShareInfo(),
                        response.GetRawResponse());
                }
                catch (Exception ex)
                {
                    ClientConfiguration.Pipeline.LogException(ex);
                    scope.Failed(ex);
                    throw;
                }
                finally
                {
                    ClientConfiguration.Pipeline.LogMethodExit(nameof(ShareClient));
                    scope.Dispose();
                }
            }
        }