Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit 9c22e41

Browse files
authored
Support of provided SAS token instead of keys (#12)
1 parent 0778804 commit 9c22e41

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,25 @@ $ bundle
5151
</match>
5252
```
5353

54-
### azure_storage_account (Required)
54+
### `azure_storage_account` (Required)
5555

5656
Your Azure Storage Account Name. This can be retrieved from Azure Management portal.
5757

58-
### azure_storage_access_key (Required)
58+
### `azure_storage_access_key` or `azure_storage_sas_token` (Required)
5959

60-
Your Azure Storage Access Key (Primary or Secondary). This also can be retrieved from Azure Management portal.
60+
Your Azure Storage Access Key (Primary or Secondary) or shared access signature (SAS) token.
61+
This also can be retrieved from Azure Management portal.
6162

62-
### azure_container (Required)
63+
### `azure_container` (Required)
6364

6465
Azure Storage Container name
6566

66-
### auto_create_container
67+
### `auto_create_container`
6768

6869
This plugin creates the Azure container if it does not already exist exist when you set 'auto_create_container' to true.
6970
The default value is `true`
7071

71-
### azure_object_key_format
72+
### `azure_object_key_format`
7273

7374
The format of Azure Storage object keys. You can use several built-in variables:
7475

@@ -114,7 +115,7 @@ The [fluent-mixin-config-placeholders](https://github.com/tagomoris/fluent-mixin
114115
azure_object_key_format %{path}/events/ts=%{time_slice}/events-%{hostname}.log
115116
```
116117

117-
### time_slice_format
118+
### `time_slice_format`
118119

119120
Format of the time used in the file name. Default is '%Y%m%d'. Use '%Y%m%d%H' to split files hourly.
120121

lib/fluent/plugin/out_azure-storage-append-blob.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class AzureStorageAppendBlobOut < Fluent::Plugin::Output
2121
config_param :path, :string, :default => ""
2222
config_param :azure_storage_account, :string, :default => nil
2323
config_param :azure_storage_access_key, :string, :default => nil, :secret => true
24+
config_param :azure_storage_sas_token, :string, :default => nil, :secret => true
2425
config_param :azure_container, :string, :default => nil
2526
config_param :azure_object_key_format, :string, :default => "%{path}%{time_slice}-%{index}.log"
2627
config_param :auto_create_container, :bool, :default => true
@@ -56,6 +57,10 @@ def configure(conf)
5657
if @azure_container.nil?
5758
raise ConfigError, 'azure_container is needed'
5859
end
60+
61+
if @azure_storage_access_key.nil? && @azure_storage_sas_token.nil?
62+
raise ConfigError, "either 'azure_storage_access_key' or 'azure_storage_sas_token' parameter must be provided"
63+
end
5964
end
6065

6166
def multi_workers_ready?
@@ -65,7 +70,17 @@ def multi_workers_ready?
6570
def start
6671
super
6772

68-
@bs = Azure::Storage::Blob::BlobService.create(storage_account_name: @azure_storage_account, storage_access_key: @azure_storage_access_key)
73+
@bs_params = {storage_account_name: @azure_storage_account}
74+
75+
if !@azure_storage_access_key.nil?
76+
@bs_params.merge!({storage_access_key: @azure_storage_access_key})
77+
end
78+
79+
if !@azure_storage_sas_token.nil?
80+
@bs_params.merge!({storage_sas_token: @azure_storage_sas_token})
81+
end
82+
83+
@bs = Azure::Storage::Blob::BlobService.create(@bs_params)
6984

7085
ensure_container
7186

0 commit comments

Comments
 (0)