Class: Azure::Storage::Client

Inherits:
Object
  • Object
show all
Includes:
Core::HttpClient, ClientOptions, Configurable
Defined in:
lib/azure/storage/client.rb

Instance Attribute Summary

Attributes included from ClientOptions

#ca_file

Attributes included from Configurable

#storage_access_key, #storage_account_name, #storage_blob_host, #storage_connection_string, #storage_queue_host, #storage_table_host

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Core::HttpClient

#agents, #reset_agents!

Methods included from ClientOptions

connection_string_mapping, env_vars_mapping, #options, #reset!, valid_options

Methods included from Configurable

#config, #configure, keys, #reset_config!, #storage_file_host

Constructor Details

#initialize(options = {}) ⇒ Azure::Storage::Client

Public: Creates an instance of [Azure::Storage::Client]

Attributes

  • options - Hash. Optional parameters.

Options

Accepted key/value pairs in options parameter are:

  • :use_development_storage - TrueClass. Whether to use storage emulator.

  • :development_storage_proxy_uri - String. Used with :use_development_storage if emulator is hosted other than localhost.

  • :storage_account_name - String. The name of the storage account.

  • :storage_access_key - Base64 String. The access key of the storage account.

  • :storage_sas_token - String. The signed access signiture for the storage account or one of its service.

  • :storage_blob_host - String. Specified Blob serivce endpoint or hostname

  • :storage_table_host - String. Specified Table serivce endpoint or hostname

  • :storage_queue_host - String. Specified Queue serivce endpoint or hostname

  • :storage_dns_suffix - String. The suffix of a regional Storage Serivce, to

  • :default_endpoints_protocol - String. http or https

  • :use_path_style_uri - String. Whether use path style URI for specified endpoints

  • :ca_file - String. File path of the CA file if having issue with SSL

The valid set of options inlcude:

  • Storage Emulator: :use_development_storage required, :development_storage_proxy_uri optionally

  • Storage account name and key: :storage_account_name and :storage_access_key required, set :storage_dns_suffix necessarily

  • Storage account name and SAS token: :storage_account_name and :storage_sas_token required, set :storage_dns_suffix necessarily

  • Specified hosts and SAS token: At least one of the service host and SAS token. It's up to user to ensure the SAS token is suitable for the serivce

  • Anonymous Blob: only :storage_blob_host, if it is to only access blobs within a container

Additional notes:

  • Specified hosts can be set when use account name with access key or sas token

  • :default_endpoints_protocol can be set if the scheme is not specified in hosts

  • Storage emulator always use path style URI

  • :ca_file is independent.

When empty options are given, it will try to read settings from Environment Variables. Refer to [Azure::Storage::ClientOptions.env_vars_mapping] for the mapping relationship


70
71
72
# File 'lib/azure/storage/client.rb', line 70

def initialize(options = {})
  reset!(options)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Azure::Storage::ClientOptions

Class Method Details

.create(options = {}) ⇒ Azure::Storage::Client

Public: Creates an instance of [Azure::Storage::Client]

Attributes

  • options - Hash. Optional parameters.

Options

Accepted key/value pairs in options parameter are:

  • :use_development_storage - TrueClass. Whether to use storage emulator.

  • :development_storage_proxy_uri - String. Used with :use_development_storage if emulator is hosted other than localhost.

  • :storage_account_name - String. The name of the storage account.

  • :storage_access_key - Base64 String. The access key of the storage account.

  • :storage_sas_token - String. The signed access signiture for the storage account or one of its service.

  • :storage_blob_host - String. Specified Blob serivce endpoint or hostname

  • :storage_table_host - String. Specified Table serivce endpoint or hostname

  • :storage_queue_host - String. Specified Queue serivce endpoint or hostname

  • :storage_dns_suffix - String. The suffix of a regional Storage Serivce, to

  • :default_endpoints_protocol - String. http or https

  • :use_path_style_uri - String. Whether use path style URI for specified endpoints

  • :ca_file - String. File path of the CA file if having issue with SSL

The valid set of options inlcude:

  • Storage Emulator: :use_development_storage required, :development_storage_proxy_uri optionally

  • Storage account name and key: :storage_account_name and :storage_access_key required, set :storage_dns_suffix necessarily

  • Storage account name and SAS token: :storage_account_name and :storage_sas_token required, set :storage_dns_suffix necessarily

  • Specified hosts and SAS token: At least one of the service host and SAS token. It's up to user to ensure the SAS token is suitable for the serivce

  • Anonymous Blob: only :storage_blob_host, if it is to only access blobs within a container

Additional notes:

  • Specified hosts can be set when use account name with access key or sas token

  • :default_endpoints_protocol can be set if the scheme is not specified in hosts

  • Storage emulator always use path style URI

  • :ca_file is independent.

When empty options are given, it will try to read settings from Environment Variables. Refer to [Azure::Storage::ClientOptions.env_vars_mapping] for the mapping relationship


133
134
135
# File 'lib/azure/storage/client.rb', line 133

def create(options={})
  Client.new(options)
end

.create_development(proxy_uri = nil) ⇒ Azure::Storage::Client

Public: Creates an instance of [Azure::Storage::Client] with Storage Emulator

Attributes

  • proxy_uri - String. Used with :use_development_storage if emulator is hosted other than localhost.


144
145
146
147
# File 'lib/azure/storage/client.rb', line 144

def create_development(proxy_uri=nil)
  proxy_uri ||= StorageServiceClientConstants::DEV_STORE_URI
  create(:use_development_storage => true, :development_storage_proxy_uri => proxy_uri)
end

.create_from_connection_string(connection_string) ⇒ Azure::Storage::Client

Public: Creates an instance of [Azure::Storage::Client] from Environment Variables

Attributes


164
165
166
# File 'lib/azure/storage/client.rb', line 164

def create_from_connection_string(connection_string)
  Client.new(connection_string)
end

.create_from_envAzure::Storage::Client

Public: Creates an instance of [Azure::Storage::Client] from Environment Variables


153
154
155
# File 'lib/azure/storage/client.rb', line 153

def create_from_env
  create
end

Instance Method Details

#blobs(options = {}) ⇒ Azure::Storage::Blob::BlobService

Azure Blob service configured from this Azure Storage client instance


76
77
78
# File 'lib/azure/storage/client.rb', line 76

def blobs(options = {})
  @blobs ||= Azure::Storage::Blob::BlobService.new(default_client(options))
end

#queues(options = {}) ⇒ Azure::Storage::Queue::QueueService

Azure Queue service configured from this Azure Storage client instance


82
83
84
# File 'lib/azure/storage/client.rb', line 82

def queues(options = {})
  @queues ||= Azure::Storage::Queue::QueueService.new(default_client(options))
end

#tables(options = {}) ⇒ Azure::Storage::Table::TableService

Azure Table service configured from this Azure Storage client instance


88
89
90
# File 'lib/azure/storage/client.rb', line 88

def tables(options = {})
  @tables ||= Azure::Storage::Table::TableService.new(default_client(options))
end