/// <summary> /// Initializes a new instance of the <see cref="ShareClient"/> /// class with an identical <see cref="Uri"/> source but the specified /// <paramref name="snapshot"/> timestamp. /// /// For more information, see <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/snapshot-share"/>. /// </summary> /// <remarks> /// Pass null or empty string to remove the snapshot returning a URL to the base share. /// </remarks> /// <param name="snapshot"> /// The snapshot identifier. /// </param> /// <returns> /// A new <see cref="ShareClient"/> instance. /// </returns> public ShareClient WithSnapshot(string snapshot) { var p = new FileUriBuilder(this.Uri) { Snapshot = snapshot }; return(new ShareClient(p.ToUri(), this._pipeline)); }
/// <summary> /// Initializes a new instance of the <see cref="ShareClient"/> /// class. /// </summary> /// <param name="connectionString"> /// A connection string includes the authentication information /// required for your application to access data in an Azure Storage /// account at runtime. /// /// For more information, <see href="https://docs.microsoft.com/en-us/azure/storage/common/storage-configure-connection-string"/>. /// </param> /// <param name="shareName"> /// The name of the share in the storage account to reference. /// </param> /// <param name="connectionOptions"> /// Optional connection options that define the transport pipeline /// policies for authentication, retries, etc., that are applied to /// every request. /// </param> /// <remarks> /// The credentials on <paramref name="connectionString"/> will override those on <paramref name="connectionOptions"/>. /// </remarks> public ShareClient(string connectionString, string shareName, FileConnectionOptions connectionOptions = default) { var conn = StorageConnectionString.Parse(connectionString); var builder = new FileUriBuilder(conn.FileEndpoint) { ShareName = shareName }; // TODO: perform a copy of the options instead var connOptions = connectionOptions ?? new FileConnectionOptions(); connOptions.Credentials = conn.Credentials; this.Uri = builder.ToUri(); this._pipeline = connOptions.Build(); }