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

Support of provided SAS token instead of keys #12

Merged
merged 8 commits into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,25 @@ $ bundle
</match>
```

### azure_storage_account (Required)
### `azure_storage_account` (Required)

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

### azure_storage_access_key (Required)
### `azure_storage_access_key` or `azure_storage_sas_token` (Required)

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

### azure_container (Required)
### `azure_container` (Required)

Azure Storage Container name

### auto_create_container
### `auto_create_container`

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

### azure_object_key_format
### `azure_object_key_format`

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

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

### time_slice_format
### `time_slice_format`

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

Expand Down
17 changes: 16 additions & 1 deletion lib/fluent/plugin/out_azure-storage-append-blob.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class AzureStorageAppendBlobOut < Fluent::Plugin::Output
config_param :path, :string, :default => ""
config_param :azure_storage_account, :string, :default => nil
config_param :azure_storage_access_key, :string, :default => nil, :secret => true
config_param :azure_storage_sas_token, :string, :default => nil, :secret => true
config_param :azure_container, :string, :default => nil
config_param :azure_object_key_format, :string, :default => "%{path}%{time_slice}-%{index}.log"
config_param :auto_create_container, :bool, :default => true
Expand Down Expand Up @@ -56,6 +57,10 @@ def configure(conf)
if @azure_container.nil?
raise ConfigError, 'azure_container is needed'
end

if @azure_storage_access_key.nil? && @azure_storage_sas_token.nil?
raise ConfigError, "either 'azure_storage_access_key' or 'azure_storage_sas_token' parameter must be provided"
end
end

def multi_workers_ready?
Expand All @@ -65,7 +70,17 @@ def multi_workers_ready?
def start
super

@bs = Azure::Storage::Blob::BlobService.create(storage_account_name: @azure_storage_account, storage_access_key: @azure_storage_access_key)
@bs_params = {storage_account_name: @azure_storage_account}

if !@azure_storage_access_key.nil?
@bs_params.merge!({storage_access_key: @azure_storage_access_key})
end

if !@azure_storage_sas_token.nil?
@bs_params.merge!({storage_sas_token: @azure_storage_sas_token})
end

@bs = Azure::Storage::Blob::BlobService.create(@bs_params)

ensure_container

Expand Down