pip_services3_azure.connect package

Submodules

Module contents

class pip_services3_azure.connect.AzureConnectionParams(values: Optional[Any] = None)

Bases: pip_services3_commons.config.ConfigParams.ConfigParams

Contains connection parameters to authenticate against Azure Functions and connect to specific Azure Function.

The class is able to compose and parse Azure Function connection parameters.

### Configuration parameters ###

  • connections:
    • uri: full connection uri with specific app and function name

    • protocol: connection protocol

    • app_name: alternative app name

    • function_name: application function name

  • credentials:
    • auth_code: authorization code or null if using custom auth

In addition to standard parameters CredentialParams may contain any number of custom parameters

See AzureConnectionResolver

Example:

static from_config(config: pip_services3_commons.config.ConfigParams.ConfigParams) pip_services3_azure.connect.AzureConnectionParams.AzureConnectionParams

Retrieves AzureConnectionParams from configuration parameters. The values are retrieves from “connection” and “credential” sections.

Parameters

config – configuration parameters

Returns

the generated AzureConnectionParams object.

static from_string(line: str) pip_services3_azure.connect.AzureConnectionParams.AzureConnectionParams

Creates a new AzureConnectionParams object filled with key-value pairs serialized as a string.

Parameters

line – a string with serialized key-value pairs as “key1=value1;key2=value2;…” Example: “Key1=123;Key2=ABC;Key3=2016-09-16T00:00:00.00Z”

Returns

a new AzureConnectionParams object.

static from_tuples(*tuples: Any) pip_services3_azure.connect.AzureConnectionParams.AzureConnectionParams

Creates a new ConfigParams object filled with provided key-args pairs called tuples. Tuples parameters contain a sequence of key1, value1, key2, value2, … pairs.

Parameters

tuples – the tuples to fill a new ConfigParams object.

Returns

a new ConfigParams object.

get_app_name() Optional[str]

Gets the Azure app name.

Returns

the Azure app name.

get_auth_code() Optional[str]

Gets the Azure auth code.

Returns

the Azure auth code.

get_function_name() Optional[str]

Gets the Azure function name.

Returns

the Azure function name.

get_function_uri() str

Gets the Azure function uri.

Returns

the Azure function uri.

get_protocol() Optional[str]

Gets the Azure function connection protocol.

Returns

the Azure function connection protocol.

static merge_configs(*configs: pip_services3_commons.config.ConfigParams.ConfigParams) pip_services3_azure.connect.AzureConnectionParams.AzureConnectionParams

Retrieves AzureConnectionParams from multiple configuration parameters. The values are retrieves from “connection” and “credential” sections.

Parameters

configs – a list with configuration parameters

Returns

the generated AzureConnectionParams object.

set_app_name(value: str)

Sets the Azure app name.

Parameters

value – a new Azure app name.

set_auth_code(value: str)

Sets the Azure auth code.

Parameters

value – a new Azure auth code.

set_function_name(value: str)

Sets the Azure function name.

Parameters

value – a new Azure function name.

set_function_uri(value: str)

Sets the Azure function uri.

Parameters

value – a new Azure function uri.

set_protocol(value: str)

Sets the Azure function connection protocol.

Parameters

value – a new Azure function connection protocol.

validate(correlation_id: Optional[str])

Validates this connection parameters

Parameters

correlation_id – (optional) transaction id to trace execution through call chain.

class pip_services3_azure.connect.AzureConnectionResolver

Bases: pip_services3_commons.config.IConfigurable.IConfigurable, pip_services3_commons.refer.IReferenceable.IReferenceable

Helper class to retrieve Azure connection and credential parameters, validate them and compose a AzureConnectionParams value.

### Configuration parameters ###
  • connections:
    • uri: full connection uri with specific app and function name

    • protocol: connection protocol

    • app_name: alternative app name

    • function_name: application function name

  • credentials:
    • auth_code: authorization code or null if using custom auth

### References ###
  • :credential-store::*:1.0 (optional) Credential stores to resolve credentials

See ConnectionParams (in the Pip.Services components package), IDiscovery (in the Pip.Services components package)

config = ConfigParams.from_tuples(
    "connection.uri", "http://myapp.azurewebsites.net/api/myfunction",
    "connection.app_name", "myapp",
    "connection.function_name", "myfunction",
    "credential.auth_code", "XXXXXXXXXX",
)

connection_resolver = AzureConnectionResolver()
connection_resolver.configure(config)
connection_resolver.set_references(references)

connection_params = connection_resolver.resolve("123")
configure(config: pip_services3_commons.config.ConfigParams.ConfigParams)

Configures component by passing configuration parameters.

Parameters

config – configuration parameters to be set.

resolve(correlation_id: Optional[str]) pip_services3_azure.connect.AzureConnectionParams.AzureConnectionParams

Resolves connection and credential parameters and generates a single AzureConnectionParams value.

Parameters

correlation_id – (optional) transaction id to trace execution through call chain.

Returns

receives AzureConnectionParams value or raise error.

set_references(references: pip_services3_commons.refer.IReferences.IReferences)

Sets references to dependent components.

Parameters

references – references to locate the component dependencies.