AzureStorage.Table (AzureStorage v0.1.6) View Source
Azure Table Service
ref. https://docs.microsoft.com/en-us/rest/api/storageservices/table-service-rest-api
alias AzureStorage.Table.EntityDescriptor
import AzureStorage.Table.EntityGenerator
{:ok, context} = AzureStorage.create_table_service("account_name", "account_key")
# build entity
entity = %EntityDescriptor{}
|> partition_key("partition_key_1000")
|> row_key("row_key_1000")
|> string("Name", "Linux")
|> int64("Val1", 42)
|> double("Val2", 42.2)
# insert entity
context |> insert_entity("table1", entity)
# retrieve entity from server
{
:ok,
%EntityDescriptor{} = existing_entity
} = context |> retrieve_entity("partition_key_value", "row_key_value")
# update entity
entity = existing_entity |> string("Name", "Ubuntu")
{:ok, %{ETag => etag}} = context |> update_entity("table1", entity)
Link to this section Summary
Functions
Create a new table in storage account
Deletes an existing entity in a table.
Delete table from storage account
The Insert Entity operation inserts a new entity into a table.
The Insert Or Merge Entity operation updates an existing entity or inserts a new entity if it does not exist in the table.
The Insert Or Replace Entity operation replaces an existing entity or inserts a new entity if it does not exist in the table.
The Merge Entity operation updates an existing entity by updating the entity's properties.
Query entities from a table storage
Retrieve an entity by PartitionKey and RowKey
The Update Entity operation updates an existing entity in a table.
Link to this section Functions
Specs
create_table(AzureStorage.Request.Context.t(), String.t()) :: {:ok, String.t()} | {:error, String.t()}
Create a new table in storage account
delete_entity(context, table_name, partition_key, row_key, etag \\ "*")
View SourceSpecs
delete_entity( AzureStorage.Request.Context.t(), String.t(), String.t(), String.t(), binary() ) :: {:ok, String.t()} | {:error, String.t()}
Deletes an existing entity in a table.
Specs
delete_table(AzureStorage.Request.Context.t(), String.t()) :: {:ok, String.t()} | {:error, String.t()}
Delete table from storage account
Specs
insert_entity( AzureStorage.Request.Context.t(), String.t(), AzureStorage.Table.EntityDescriptor.t() ) :: {:ok, map()} | {:error, String.t()}
The Insert Entity operation inserts a new entity into a table.
ref. https://docs.microsoft.com/en-us/rest/api/storageservices/insert-entity
alias AzureStorage.Table.EntityDescriptor
import AzureStorage.Table.EntityGenerator
entity = %EntityDescriptor{}
|> partition_key("partition_key_1")
|> row_key("row_key_1")
|> string("Message", "Hello World")
context |> AzureStorage.Table.insert_entity("table1", entity)
# {:ok, %{"ETag" => ...}}
The Insert Or Merge Entity operation updates an existing entity or inserts a new entity if it does not exist in the table.
Because this operation can insert or update an entity, it is also known as an upsert operation.
The Insert Or Replace Entity operation replaces an existing entity or inserts a new entity if it does not exist in the table.
Because this operation can insert or update an entity, it is also known as an upsert operation.
The Merge Entity operation updates an existing entity by updating the entity's properties.
This operation does not replace the existing entity, as the Update Entity operation does.
Specs
query_entities( AzureStorage.Request.Context.t(), AzureStorage.Table.Query.t(), keyword() ) :: {:ok, list(), String.t()} | {:error, String.t()}
Query entities from a table storage
Supported options
:as
- return result asjson
orAzureStorage.Table.EntityDescriptor
The default value is:json
.:continuation_token
- Continuation token required to fetch paged results The default value is""
.
retrieve_entity(context, table_name, partition_key, row_key, options \\ [])
View SourceRetrieve an entity by PartitionKey and RowKey
Supported options
:as
- return result asjson
orAzureStorage.Table.EntityDescriptor
The default value is:json
.
context |> AzureStorage.Table.retrieve_entity("table1", "partition_key", "row_key", as: :json)
# {:ok, %{...}}
context |> AzureStorage.Table.retrieve_entity("table1", "partition_key", "row_key", as: :entity)
# {:ok, %EntityDescriptor{}}
The Update Entity operation updates an existing entity in a table.
The Update Entity operation replaces the entire entity and can be used to remove properties.