Awesome
ExAzure
Azure wrapper for Elixir using :erlazure.
Installation
- Add
:ex_azure
to your list of dependencies inmix.exs
:
def deps do
[{:ex_azure, "~> 0.1.0"}]
end
- Ensure
ex_azure
is started before your application:
def application do
[applications: [:ex_azure]]
end
- By default, ExAzure using the following configuration:
config :ex_azure,
account: System.get_env("AZURE_ACCOUNT"),
access_key: System.get_env("AZURE_ACCESS_KEY")
Usage
For now, the ExAzure is a simple wrapper to make the calls to the erlazure
.
This way, you can just use ExAzure.request/3
or ExAzure.request!/3
to make the calls.
Access "Implemented API functions" in :erlazure
to all implemented functions.
examples:
# get a list of containers
ExAzure.request(:list_containers)
{:ok,
%{body: [{:blob_container, 'uploads', [],
[last_modified: 'Tue, 05 Jul 2016 17:15:12 GMT',
etag: '"0x8D3A4F7ECC4541F"', lease_status: :unlocked,
lease_state: :available], []}], headers: [next_marker: []]}}
# get a list of blobs in "uploads" container
ExAzure.request(:list_blobs, ["uploads"])
{:ok, %{body: [], headers: [next_marker: []]}}
example of errors:
# no matched function
ExAzure.request(:list_blobs)
{:error,
%UndefinedFunctionError{arity: 1, function: :list_blobs, module: :erlazure,
reason: nil}}
# raised error using request!/3
ExAzure.request!(:list_blobs)
** (UndefinedFunctionError) function :erlazure.list_blobs/1 is undefined or private. Did you mean one of:
* list_blobs/2
* list_blobs/3
* list_blobs/4
(erlazure) :erlazure.list_blobs(#PID<0.134.0>)
(ex_azure) lib/ex_azure.ex:43: ExAzure.do_request/3
Test
- Getting your
AZURE_ACCOUNT
andAZURE_ACCESS_KEY
in ( https://portal.azure.com ) and adding to.env
file:
echo "AZURE_ACCOUNT=value" >> .env
echo "AZURE_ACCESS_KEY=value" >> .env
see
.env.sample
for example.
- run tests
azk shell -t -- mix do deps.get
azk shell -t -- mix test
Contributing
- Fork it ( https://github.com/azukiapp/ex_azure/fork )
- Create your feature branch (git checkout -b feature/new_feature_name)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin feature/new_feature_name)
- Create a new Pull Request
TODO
-
Add more docs:
-
Add clients to a syntaxe more elegant and greater flexibility: sample:
# use ExAzure.Blobs.list("uploads") # instead of ExAzure.request(:list_blobs, ["uploads"])
-
Add CI s