Skip to content

Commit 9356db3

Browse files
authored
Merge pull request rails#52863 from zzak/asto/deprecate-azure
Deprecate ActiveStorage::Service::AzureStorageService
2 parents d7bd5b1 + 4dae45c commit 9356db3

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

activestorage/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Deprecate `ActiveStorage::Service::AzureStorageService`.
2+
3+
*zzak*
4+
15
* Improve `ActiveStorage::Filename#sanitized` method to handle special characters more effectively.
26
Replace the characters `"*?<>` with `-` if they exist in the Filename to match the Filename convention of Win OS.
37

activestorage/lib/active_storage/service/azure_storage_service.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ class Service::AzureStorageService < Service
1515
attr_reader :client, :container, :signer
1616

1717
def initialize(storage_account_name:, storage_access_key:, container:, public: false, **options)
18+
ActiveStorage.deprecator.warn <<~MSG.squish
19+
`ActiveStorage::Service::AzureStorageService` is deprecated and will be
20+
removed in Rails 8.1.
21+
Please try the `azure-blob` gem instead.
22+
This gem is not maintained by the Rails team, so please test your applications before deploying to production.
23+
MSG
24+
1825
@client = Azure::Storage::Blob::BlobService.create(storage_account_name: storage_account_name, storage_access_key: storage_access_key, **options)
1926
@signer = Azure::Storage::Common::Core::Auth::SharedAccessSignature.new(storage_account_name, storage_access_key)
2027
@container = container

activestorage/test/service/configurator_test.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,22 @@ class ActiveStorage::Service::ConfiguratorTest < ActiveSupport::TestCase
2020
ActiveStorage::Service::Configurator.build(:bigfoot, {})
2121
end
2222
end
23+
24+
test "azure service is deprecated" do
25+
msg = <<~MSG.squish
26+
`ActiveStorage::Service::AzureStorageService` is deprecated and will be
27+
removed in Rails 8.1.
28+
Please try the `azure-blob` gem instead.
29+
This gem is not maintained by the Rails team, so please test your applications before deploying to production.
30+
MSG
31+
32+
assert_deprecated(msg, ActiveStorage.deprecator) do
33+
ActiveStorage::Service::Configurator.build(:azure, azure: {
34+
service: "AzureStorage",
35+
storage_account_name: "test_account",
36+
storage_access_key: Base64.encode64("test_access_key").strip,
37+
container: "container"
38+
})
39+
end
40+
end
2341
end

0 commit comments

Comments
 (0)