pip_services3_azure.services package
Submodules
Module contents
- class pip_services3_azure.services.AzureFunctionAction(cmd: str, schema: pip_services3_commons.validate.Schema.Schema, action: Callable[[azure.functions._http.HttpRequest], azure.functions._http.HttpResponse])
Bases:
object- action(context: azure.functions._http.HttpRequest) azure.functions._http.HttpResponse
Action to be executed
- Parameters
context – action context
- class pip_services3_azure.services.AzureFunctionService(name: Optional[str])
Bases:
pip_services3_azure.services.IAzureFunctionService.IAzureFunctionService,pip_services3_commons.run.IOpenable.IOpenable,pip_services3_commons.config.IConfigurable.IConfigurable,pip_services3_commons.refer.IReferenceable.IReferenceableAbstract service that receives remove calls via Azure Function protocol.
This service is intended to work inside AzureFunction container that exposes registered actions externally.
- ### Configuration parameters ###
- dependencies:
controller: override for Controller dependency
- ### References ###
Example:
class MyAzureFunctionService(AzureFunctionService): def __init__(self): super().__init__('v1.myservice') self._dependency_resolver.put( "controller", Descriptor("mygroup", "controller", "*", "*", "1.0") ) self.__controller: IMyController = None def set_references(self, references: IReferences): super().set_references(references) self.__controller = self._dependency_resolver.get_required("controller") def __get_mydata(self, context: HttpRequest): data = context.get_json() correlation_id = data.get('correlation_id') id = data.get('id') return self.__controller.get_my_data(correlation_id, id) def register(self): self._register_action( 'get_mydata', None, self.__get_mydata ) ... service = MyAzureFunctionService() service.configure(ConfigParams.from_tuples( "connection.protocol", "http", "connection.host", "localhost", "connection.port", 8080 )) service.set_references(References.fromTuples( Descriptor("mygroup", "controller", "default", "default", "1.0"), controller )) service.open("123")
- act(context: azure.functions._http.HttpRequest) azure.functions._http.HttpResponse
Calls registered action in this Azure Function. “cmd” parameter in the action parameters determine what action shall be called.
This method shall only be used in testing.
- Parameters
context – the context context.
- close(correlation_id: Optional[str])
Closes component and frees used resources.
- Parameters
correlation_id – (optional) transaction id to trace execution through call chain.
- configure(config: pip_services3_commons.config.ConfigParams.ConfigParams)
Configures component by passing configuration parameters.
- Parameters
config – configuration parameters to be set.
- get_actions() List[pip_services3_azure.services.AzureFunctionAction.AzureFunctionAction]
Get all actions supported by the service.
- Returns
an array with supported actions.
- is_open() bool
Checks if the component is opened.
- Returns
true if the component has been opened and false otherwise.
- open(correlation_id: Optional[str])
Opens the component.
- Parameters
correlation_id – (optional) transaction id to trace execution through call chain.
- abstract register()
Registers all service routes in HTTP endpoint.
This method is called by the service and must be overridden in child classes.
- set_references(references: pip_services3_commons.refer.IReferences.IReferences)
Sets references to dependent components.
- Parameters
references – references to locate the component dependencies.
- class pip_services3_azure.services.CommandableAzureFunctionService(name: str)
Bases:
pip_services3_azure.services.AzureFunctionService.AzureFunctionServiceAbstract service that receives commands via Azure Function protocol to operations automatically generated for commands defined in
ICommandablecomponents. Each command is exposed as invoke method that receives command name and parameters.Commandable services require only 3 lines of code to implement a robust external Azure Function-based remote interface.
This service is intended to work inside Azure Function container that exploses registered actions externally.
- ### Configuration parameters ###
- dependencies:
controller: override for Controller dependency
- ### References ###
See:
AzureFunctionServiceExample:
- register()
Registers all actions in Azure Function.
- class pip_services3_azure.services.IAzureFunctionService
Bases:
abc.ABC- abstract get_actions() List[pip_services3_azure.services.AzureFunctionAction.AzureFunctionAction]