CommandableAzureFunctionService

Abstract service that receives commands via the Azure Function protocol to operations automatically generated for commands defined in ICommandable components.

Implements: AzureFunctionService

Description

The CommandableAzureFunctionService class allows you to create abstract services that receive commands via the Azure Function protocols to operations automatically generated for commnads defined in ICommandable components.

Important points

  • Each command is exposed as an invoke method that receives a command’s 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 an Azure Function container that exploses registered actions externally.

Configuration parameters

  • dependencies:
    • controller: override for Controller dependency

References

  • *:logger:*:*:1.0: (optional) ILogger components to pass log messages.
  • *:counters:*:*:1.0: (optional) ICounters components to pass collected measurements.

Constructors

CommandableAzureFunctionService(name: str)

  • name: str - service’s name.

Instance methods

_get_parameters

Returns body from Azure Function context. This method can be overloaded in child classes

_get_parameters(context: HttpRequest): Parameters

register

Registers all actions in Azure Function.

register()

Examples

class MyCommandableAzureFunctionService(CommandableAzureFunctionService):
    def __init__(self):
        super(MyCommandableAzureFunctionService, self).__init__()
        self._dependency_resolver.put(
            "controller", Descriptor("mygroup", "controller", "*", "*", "1.0")
        )

service = MyCommandableAzureFunctionService()
service.set_references(References.fromTuples(
    Descriptor("mygroup", "controller", "default", "default", "1.0"), controller
))

service.open("123")
print("The Azure Function service is running")