diff --git a/CloudStorageAccount.sln b/CloudStorageAccount.sln index 78e3683..2466c19 100644 --- a/CloudStorageAccount.sln +++ b/CloudStorageAccount.sln @@ -12,6 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution readme.md = readme.md EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudStorageAccount.Source", "src\CloudStorageAccount.Source\CloudStorageAccount.Source.csproj", "{29911CE6-86EE-41F6-AB64-1C26DAEC2061}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -26,6 +28,10 @@ Global {3D75F7F3-DDF9-4BD5-80BF-7A102667DC34}.Debug|Any CPU.Build.0 = Debug|Any CPU {3D75F7F3-DDF9-4BD5-80BF-7A102667DC34}.Release|Any CPU.ActiveCfg = Release|Any CPU {3D75F7F3-DDF9-4BD5-80BF-7A102667DC34}.Release|Any CPU.Build.0 = Release|Any CPU + {29911CE6-86EE-41F6-AB64-1C26DAEC2061}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {29911CE6-86EE-41F6-AB64-1C26DAEC2061}.Debug|Any CPU.Build.0 = Debug|Any CPU + {29911CE6-86EE-41F6-AB64-1C26DAEC2061}.Release|Any CPU.ActiveCfg = Release|Any CPU + {29911CE6-86EE-41F6-AB64-1C26DAEC2061}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/CloudStorageAccount.Source/CloudStorageAccount.Source.csproj b/src/CloudStorageAccount.Source/CloudStorageAccount.Source.csproj new file mode 100644 index 0000000..799fd40 --- /dev/null +++ b/src/CloudStorageAccount.Source/CloudStorageAccount.Source.csproj @@ -0,0 +1,33 @@ + + + + Devlooped + netstandard2.0 + Devlooped.CloudStorageAccount.Source + Devlooped.CloudStorageAccount.Source + CloudStorageAccount for Azure Storage v12+ + https://clarius.org/CloudStorageAccount + false + true + readme.md + + + + + + + + + + + + + + + + + %(Filename)%(Extension) + + + + diff --git a/src/CloudStorageAccount.Source/Devlooped.CloudStorageAccount.Source.targets b/src/CloudStorageAccount.Source/Devlooped.CloudStorageAccount.Source.targets new file mode 100644 index 0000000..566eb72 --- /dev/null +++ b/src/CloudStorageAccount.Source/Devlooped.CloudStorageAccount.Source.targets @@ -0,0 +1,10 @@ + + + + + false + Devlooped\CloudStorageAccount\%(Filename)%(Extension) + + + + \ No newline at end of file diff --git a/src/CloudStorageAccount.Source/readme.md b/src/CloudStorageAccount.Source/readme.md new file mode 100644 index 0000000..cc57bbb --- /dev/null +++ b/src/CloudStorageAccount.Source/readme.md @@ -0,0 +1,56 @@ +The new unified Azure Storage and Tables client libraries do away with the +[CloudStorageAccount](https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.storage.cloudstorageaccount?view=azure-dotnet) +that was typically used. This makes migration a bit painful, as noted in: + +* [Azure.Data.Tables](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/tables/Azure.Data.Tables/MigrationGuide.md) migration guide +* [Azure.Storage.Blobs](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Blobs/AzureStorageNetMigrationV12.md) migration guide + +This package provides a (mostly) drop-in replacement, with source code brought (and updated) +from the [original location](https://github.com/Azure/azure-storage-net/blob/master/Lib/Common/CloudStorageAccount.cs). +Just replace the old namespace `Microsoft.Azure.Storage` with `Devlooped` and you're mostly done. + +In addition to the legacy, backwards-compatible APIs so projects compile right away with this +package when upgrading to v12 client libraries, there are a few newer APIs that are more aligned +with the new APIs, such as: + +* CloudStorageAccount.CreateBlobServiceClient (extension method) +* CloudStorageAccount.CreateQueueServiceClient (extension method) +* CloudStorageAccount.CreateTableServiceClient (extension method) + +These make it more explicit that you're creating instances of the new service clients. + +## Usage + +```csharp +var account = CloudStorageAccount.DevelopmentStorageAccount; + +var tableService = account.CreateTableServiceClient(); +// legacy invocation works too: account.CreateCloudTableClient(); + +// Can also access the endpoints for each service: +Console.WriteLine(account.BlobEndpoint); +Console.WriteLine(account.QueueEndpoint); +Console.WriteLine(account.TableEndpoint); +``` + +## Visibily + +This source-only package provides all types as partial and without an explicit +visibility. This allows you to decide whether you want to make the types a +public part of your project's API surface or not. Should you decide to make +types public, you can use the approach used to compile the binary version +[as a template](https://github.com/devlooped/CloudStorageAccount/blob/main/src/CloudStorageAccount/Visibility.cs): + +```csharp +namespace Devlooped; + +public partial class BlobAccountExtensions { } + +public partial class CloudStorageAccount { } + +public partial class QueueAccountExtensions { } + +public partial class StorageCredentials { } + +public partial class TableAccountExtensions { } +``` \ No newline at end of file diff --git a/src/CloudStorageAccount/BlobAccountExtensions.cs b/src/CloudStorageAccount/BlobAccountExtensions.cs index cce6f08..633a00e 100644 --- a/src/CloudStorageAccount/BlobAccountExtensions.cs +++ b/src/CloudStorageAccount/BlobAccountExtensions.cs @@ -9,7 +9,7 @@ namespace Devlooped; /// Provides the extension method. /// [EditorBrowsable(EditorBrowsableState.Never)] -public static class BlobAccountExtensions +static partial class BlobAccountExtensions { /// /// Creates a Blob service client from the given account. diff --git a/src/CloudStorageAccount/CloudStorageAccount.cs b/src/CloudStorageAccount/CloudStorageAccount.cs index b50f193..3a5c943 100644 --- a/src/CloudStorageAccount/CloudStorageAccount.cs +++ b/src/CloudStorageAccount/CloudStorageAccount.cs @@ -11,7 +11,7 @@ namespace Devlooped; /// /// Represents a Microsoft Azure Storage account. /// -public class CloudStorageAccount +partial class CloudStorageAccount { /// /// The setting name for using the development storage. diff --git a/src/CloudStorageAccount/CloudStorageAccount.csproj b/src/CloudStorageAccount/CloudStorageAccount.csproj index a75d780..e57ff76 100644 --- a/src/CloudStorageAccount/CloudStorageAccount.csproj +++ b/src/CloudStorageAccount/CloudStorageAccount.csproj @@ -10,6 +10,7 @@ + diff --git a/src/CloudStorageAccount/QueueAccountExtensions.cs b/src/CloudStorageAccount/QueueAccountExtensions.cs index d9100c5..efa8d7f 100644 --- a/src/CloudStorageAccount/QueueAccountExtensions.cs +++ b/src/CloudStorageAccount/QueueAccountExtensions.cs @@ -9,7 +9,7 @@ namespace Devlooped; /// Provides the extension method. /// [EditorBrowsable(EditorBrowsableState.Never)] -public static class QueueAccountExtensions +static partial class QueueAccountExtensions { /// /// Creates a Queue service client from the given account. diff --git a/src/CloudStorageAccount/StorageCredentials.cs b/src/CloudStorageAccount/StorageCredentials.cs index f06fdd4..876b259 100644 --- a/src/CloudStorageAccount/StorageCredentials.cs +++ b/src/CloudStorageAccount/StorageCredentials.cs @@ -8,7 +8,7 @@ namespace Devlooped; /// Represents a set of credentials used to authenticate access /// to a Microsoft Azure storage account. /// -public class StorageCredentials +partial class StorageCredentials { /// /// Initializes a new instance of the with diff --git a/src/CloudStorageAccount/TableAccountExtensions.cs b/src/CloudStorageAccount/TableAccountExtensions.cs index d4d754e..d43e504 100644 --- a/src/CloudStorageAccount/TableAccountExtensions.cs +++ b/src/CloudStorageAccount/TableAccountExtensions.cs @@ -9,7 +9,7 @@ namespace Devlooped; /// Provides the extension method. /// [EditorBrowsable(EditorBrowsableState.Never)] -public static class TableAccountExtensions +static partial class TableAccountExtensions { /// /// Creates a Table service client from the given account. diff --git a/src/CloudStorageAccount/Visibility.cs b/src/CloudStorageAccount/Visibility.cs new file mode 100644 index 0000000..1bd8bfe --- /dev/null +++ b/src/CloudStorageAccount/Visibility.cs @@ -0,0 +1,11 @@ +namespace Devlooped; + +public partial class BlobAccountExtensions { } + +public partial class CloudStorageAccount { } + +public partial class QueueAccountExtensions { } + +public partial class StorageCredentials { } + +public partial class TableAccountExtensions { } \ No newline at end of file diff --git a/src/CloudStorageAccount/readme.md b/src/CloudStorageAccount/readme.md new file mode 100644 index 0000000..07f4002 --- /dev/null +++ b/src/CloudStorageAccount/readme.md @@ -0,0 +1,34 @@ +The new unified Azure Storage and Tables client libraries do away with the +[CloudStorageAccount](https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.storage.cloudstorageaccount?view=azure-dotnet) +that was typically used. This makes migration a bit painful, as noted in: + +* [Azure.Data.Tables](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/tables/Azure.Data.Tables/MigrationGuide.md) migration guide +* [Azure.Storage.Blobs](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Blobs/AzureStorageNetMigrationV12.md) migration guide + +This package provides a (mostly) drop-in replacement, with source code brought (and updated) +from the [original location](https://github.com/Azure/azure-storage-net/blob/master/Lib/Common/CloudStorageAccount.cs). +Just replace the old namespace `Microsoft.Azure.Storage` with `Devlooped` and you're mostly done. + +In addition to the legacy, backwards-compatible APIs so projects compile right away with this +package when upgrading to v12 client libraries, there are a few newer APIs that are more aligned +with the new APIs, such as: + +* CloudStorageAccount.CreateBlobServiceClient (extension method) +* CloudStorageAccount.CreateQueueServiceClient (extension method) +* CloudStorageAccount.CreateTableServiceClient (extension method) + +These make it more explicit that you're creating instances of the new service clients. + +## Usage + +```csharp +var account = CloudStorageAccount.DevelopmentStorageAccount; + +var tableService = account.CreateTableServiceClient(); +// legacy invocation works too: account.CreateCloudTableClient(); + +// Can also access the endpoints for each service: +Console.WriteLine(account.BlobEndpoint); +Console.WriteLine(account.QueueEndpoint); +Console.WriteLine(account.TableEndpoint); +```