Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement ctor accepting a connection string #14674

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/tables/Azure.Data.Tables/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Release History

## 1.0.0-preview.1 (Unreleased)
## 3.0.0-beta.1 (Unreleased)
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public partial interface ITableEntity
public partial class TableClient
{
protected TableClient() { }
public TableClient(string tableName, string connectionString) { }
public TableClient(string tableName, string connectionString, Azure.Data.Tables.TableClientOptions options = null) { }
public TableClient(string tableName, System.Uri endpoint, Azure.Data.Tables.TableClientOptions options = null) { }
public TableClient(string tableName, System.Uri endpoint, Azure.Data.Tables.TableSharedKeyCredential credential) { }
public TableClient(string tableName, System.Uri endpoint, Azure.Data.Tables.TableSharedKeyCredential credential, Azure.Data.Tables.TableClientOptions options = null) { }
Expand Down Expand Up @@ -86,6 +88,8 @@ public void Clear() { }
public partial class TableServiceClient
{
protected TableServiceClient() { }
public TableServiceClient(string connectionString) { }
public TableServiceClient(string connectionString, Azure.Data.Tables.TableClientOptions options = null) { }
public TableServiceClient(System.Uri endpoint) { }
public TableServiceClient(System.Uri endpoint, Azure.Data.Tables.TableClientOptions options = null) { }
public TableServiceClient(System.Uri endpoint, Azure.Data.Tables.TableSharedKeyCredential credential) { }
Expand Down
2 changes: 1 addition & 1 deletion sdk/tables/Azure.Data.Tables/src/Azure.Data.Tables.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<Description>This client library enables working with the Microsoft Azure Table service</Description>
<AssemblyTitle>Microsoft Azure.Data.Tables client library</AssemblyTitle>
<Version>1.0.0-preview.1</Version>
<Version>3.0.0-beta.1</Version>
<DefineConstants>TableSDK;$(DefineConstants)</DefineConstants>
<PackageTags>Microsoft Azure Tables;Microsoft;Azure;Tables;Table;$(PackageCommonTags)</PackageTags>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
Expand Down
61 changes: 60 additions & 1 deletion sdk/tables/Azure.Data.Tables/src/TableClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,66 @@ public TableClient(string tableName, Uri endpoint, TableSharedKeyCredential cred
Argument.AssertNotNull(credential, nameof(credential));
}


/// <summary>
/// Initializes a new instance of the <see cref="TableServiceClient"/>.
/// </summary>
/// <param name="tableName">The name of the table with which this client instance will interact.</param>
/// <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/azure/storage/common/storage-configure-connection-string">
/// Configure Azure Storage connection strings</see>.
/// </param>
public TableClient(string tableName, string connectionString)
: this(tableName, connectionString, default)
{ }

/// <summary>
/// Initializes a new instance of the <see cref="TableServiceClient"/>.
/// </summary>
/// <param name="tableName">The name of the table with which this client instance will interact.</param>
/// <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/azure/storage/common/storage-configure-connection-string">
/// Configure Azure Storage connection strings</see>.
/// </param>
/// <param name="options">
/// Optional client options that define the transport pipeline policies for authentication, retries, etc., that are applied to every request.
/// </param>
public TableClient(string tableName, string connectionString, TableClientOptions options = null)
{
Argument.AssertNotNull(connectionString, nameof(connectionString));

TableConnectionString connString = TableConnectionString.Parse(connectionString);

options ??= new TableClientOptions();
var endpointString = connString.TableStorageUri.PrimaryUri.ToString();

TableSharedKeyPipelinePolicy policy = connString.Credentials switch
{
TableSharedKeyCredential credential => new TableSharedKeyPipelinePolicy(credential),
_ => default
};

options ??= new TableClientOptions();
HttpPipeline pipeline = HttpPipelineBuilder.Build(options, policy);

_diagnostics = new ClientDiagnostics(options);
_tableOperations = new TableRestClient(_diagnostics, pipeline, endpointString);
_version = options.VersionString;
_table = tableName;
_format = OdataMetadataFormat.ApplicationJsonOdataMinimalmetadata;
_isPremiumEndpoint = TableServiceClient.IsPremiumEndpoint(connString.TableStorageUri.PrimaryUri);
}

internal TableClient(string tableName, Uri endpoint, TableSharedKeyPipelinePolicy policy, TableClientOptions options)
{
Argument.AssertNotNull(tableName, nameof(tableName));
Expand All @@ -103,7 +163,6 @@ internal TableClient(string tableName, Uri endpoint, TableSharedKeyPipelinePolic
_table = tableName;
_format = OdataMetadataFormat.ApplicationJsonOdataMinimalmetadata;
_isPremiumEndpoint = TableServiceClient.IsPremiumEndpoint(endpoint);
;
}

internal TableClient(string table, TableRestClient tableOperations, string version, ClientDiagnostics diagnostics, bool isPremiumEndpoint)
Expand Down
Loading