diff --git a/src/ElCamino.AspNetCore.Identity.AzureTable.Model/ElCamino.AspNetCore.Identity.AzureTable.Model.csproj b/src/ElCamino.AspNetCore.Identity.AzureTable.Model/ElCamino.AspNetCore.Identity.AzureTable.Model.csproj
index 047cf0c..c6dc03f 100644
--- a/src/ElCamino.AspNetCore.Identity.AzureTable.Model/ElCamino.AspNetCore.Identity.AzureTable.Model.csproj
+++ b/src/ElCamino.AspNetCore.Identity.AzureTable.Model/ElCamino.AspNetCore.Identity.AzureTable.Model.csproj
@@ -32,7 +32,7 @@
-
+
diff --git a/src/ElCamino.AspNetCore.Identity.AzureTable.Model/IdentityConfiguration.cs b/src/ElCamino.AspNetCore.Identity.AzureTable.Model/IdentityConfiguration.cs
index 08e3cce..9410f2c 100644
--- a/src/ElCamino.AspNetCore.Identity.AzureTable.Model/IdentityConfiguration.cs
+++ b/src/ElCamino.AspNetCore.Identity.AzureTable.Model/IdentityConfiguration.cs
@@ -1,6 +1,9 @@
// MIT License Copyright 2020 (c) David Melendez. All rights reserved. See License.txt in the project root for license information.
+using System;
+using Azure.Core;
+
namespace ElCamino.AspNetCore.Identity.AzureTable.Model
{
public class IdentityConfiguration
@@ -8,12 +11,15 @@ public class IdentityConfiguration
public string TablePrefix { get; set; }
public string StorageConnectionString { get; set; }
-
+
public string IndexTableName { get; set; }
public string UserTableName { get; set; }
public string RoleTableName { get; set; }
+ public Uri StorageConnectionUri { get; set; }
+ public TokenCredential TokenCredential { get; set; }
+
}
}
diff --git a/src/ElCamino.AspNetCore.Identity.AzureTable/ElCamino.AspNetCore.Identity.AzureTable.csproj b/src/ElCamino.AspNetCore.Identity.AzureTable/ElCamino.AspNetCore.Identity.AzureTable.csproj
index f72c68f..1ba5a01 100644
--- a/src/ElCamino.AspNetCore.Identity.AzureTable/ElCamino.AspNetCore.Identity.AzureTable.csproj
+++ b/src/ElCamino.AspNetCore.Identity.AzureTable/ElCamino.AspNetCore.Identity.AzureTable.csproj
@@ -33,7 +33,7 @@
-
+
diff --git a/src/ElCamino.AspNetCore.Identity.AzureTable/IdentityCloudContext.cs b/src/ElCamino.AspNetCore.Identity.AzureTable/IdentityCloudContext.cs
index 15ca826..a87bf32 100644
--- a/src/ElCamino.AspNetCore.Identity.AzureTable/IdentityCloudContext.cs
+++ b/src/ElCamino.AspNetCore.Identity.AzureTable/IdentityCloudContext.cs
@@ -26,7 +26,32 @@ public IdentityCloudContext(IdentityConfiguration config)
protected virtual void Initialize(IdentityConfiguration config)
{
_config = config;
- _client = new TableServiceClient(_config.StorageConnectionString);
+
+ if (string.IsNullOrEmpty(_config.StorageConnectionString) && _config.StorageConnectionUri == null)
+ {
+ throw new ArgumentNullException(nameof(config.StorageConnectionString), "Either StorageConnectionString or StorageConnectionUri are required");
+ }
+ else if (!string.IsNullOrEmpty(_config.StorageConnectionString))
+ {
+ _client = new TableServiceClient(_config.StorageConnectionString);
+
+ if (_config.TokenCredential != null)
+ {
+ //If we've been passed a TokenCredential we can use that instead of the credentials in the connection string
+ _client = new TableServiceClient(_client.Uri, _config.TokenCredential);
+ }
+ }
+ else if (_config.StorageConnectionUri != null)
+ {
+ if (config.TokenCredential == null)
+ {
+ throw new ArgumentNullException(nameof(config.TokenCredential), "TokenCredential is required when Uri is specified");
+ }
+ else
+ {
+ _client = new TableServiceClient(_client.Uri, config.TokenCredential);
+ }
+ }
_indexTable = _client.GetTableClient(FormatTableNameWithPrefix(!string.IsNullOrWhiteSpace(_config.IndexTableName) ? _config.IndexTableName : TableConstants.TableNames.IndexTable));
_roleTable = _client.GetTableClient(FormatTableNameWithPrefix(!string.IsNullOrWhiteSpace(_config.RoleTableName) ? _config.RoleTableName : TableConstants.TableNames.RolesTable));
diff --git a/src/ElCamino.Azure.Data.Tables/ElCamino.Azure.Data.Tables.csproj b/src/ElCamino.Azure.Data.Tables/ElCamino.Azure.Data.Tables.csproj
index 1229919..da9e45e 100644
--- a/src/ElCamino.Azure.Data.Tables/ElCamino.Azure.Data.Tables.csproj
+++ b/src/ElCamino.Azure.Data.Tables/ElCamino.Azure.Data.Tables.csproj
@@ -41,7 +41,7 @@
-
+
diff --git a/src/ElCamino.Identity.AzureTable.DataUtility/ElCamino.Identity.AzureTable.DataUtility.csproj b/src/ElCamino.Identity.AzureTable.DataUtility/ElCamino.Identity.AzureTable.DataUtility.csproj
index 89666d1..683daa6 100644
--- a/src/ElCamino.Identity.AzureTable.DataUtility/ElCamino.Identity.AzureTable.DataUtility.csproj
+++ b/src/ElCamino.Identity.AzureTable.DataUtility/ElCamino.Identity.AzureTable.DataUtility.csproj
@@ -1,4 +1,4 @@
-
+
net7.0
@@ -41,7 +41,8 @@
-
+
+
diff --git a/tests/ElCamino.AspNetCore.Identity.AzureTable.Tests/ElCamino.AspNetCore.Identity.AzureTable.Tests.csproj b/tests/ElCamino.AspNetCore.Identity.AzureTable.Tests/ElCamino.AspNetCore.Identity.AzureTable.Tests.csproj
index a03e230..0c87b01 100644
--- a/tests/ElCamino.AspNetCore.Identity.AzureTable.Tests/ElCamino.AspNetCore.Identity.AzureTable.Tests.csproj
+++ b/tests/ElCamino.AspNetCore.Identity.AzureTable.Tests/ElCamino.AspNetCore.Identity.AzureTable.Tests.csproj
@@ -56,7 +56,7 @@
-
+