functions Package
Contains functionality for packaging Azure Machine Learning models for deployment to Azure Functions.
Azure Functions allows you to run small pieces of code (called "functions") that can be triggered by a specified event, such as changes in data, or on a schedule as often needed in machine learning workflows. For more information, see An introduction to Azure Functions.
With the functions in this package, you can create Azure Functions applications from models registered in your Azure Machine Learning workspace. Each function returns a ModelPackage object representing either a Docker image that encapsulates your model and its dependencies or a Dockerfile build context.
For examples of using Azure Functions for machine learning, see Tutorial: Apply machine learning models in Azure Functions with Python and TensorFlow and Tutorial: Deploy a pre-trained image classification model to Azure Functions with PyTorch.
Functions
package
Create a model package in the form of a Docker image or Dockerfile build context.
This function creates a model package for use in Azure Functions with the specified trigger
type.
The other functions in this package, create model packages for specific trigger types. For more information,
see Azure Functions triggers and
bindings.
package(workspace, models, inference_config, generate_dockerfile=False, functions_enabled=False, trigger=None, **kwargs)
Parameters
Name | Description |
---|---|
workspace
Required
|
The workspace in which to create the package. |
models
Required
|
A list of Model objects to include in the package. Can be an empty list. |
inference_config
Required
|
An InferenceConfig object to configure the operation of the models. This must include an Environment object. |
generate_dockerfile
|
Whether to create a Dockerfile that can be run locally instead of building an image. Default value: False
|
functions_enabled
|
Whether Azure Functions should be enabled in the packaged container. Default value: False
|
trigger
|
An optional trigger for the function. The values can be "blob", "http", or "service_bus_queue". Default value: None
|
kwargs
Required
|
Any of the arguments for a specific package function defined in this module. For example,
for the |
Returns
Type | Description |
---|---|
A ModelPackage object. |
Exceptions
Type | Description |
---|---|
Invalid trigger specified. |
package_blob
Create an Azure Functions model package as a Docker image or Dockerfile build context with a blob trigger.
package_blob(workspace, models, inference_config, generate_dockerfile=False, input_path=None, output_path=None)
Parameters
Name | Description |
---|---|
workspace
Required
|
The workspace in which to create the package. |
models
Required
|
A list of Model objects to include in the package. Can be an empty list. |
inference_config
Required
|
An InferenceConfig object to configure the operation of the models. This must include an Environment object. |
generate_dockerfile
|
Whether to create a Dockerfile that can be run locally instead of building an image. Default value: False
|
input_path
|
Input path for the blob trigger option. Default value: None
|
output_path
|
Output path for the blob trigger option. Default value: None
|
Returns
Type | Description |
---|---|
A ModelPackage object. |
Exceptions
Type | Description |
---|---|
Invalid trigger specified. |
package_http
Create an Azure Functions model package as a Docker image or Dockerfile build context with an HTTP trigger.
package_http(workspace, models, inference_config, generate_dockerfile=False, auth_level=None)
Parameters
Name | Description |
---|---|
workspace
Required
|
The workspace in which to create the package. |
models
Required
|
A list of Model objects to include in the package. Can be an empty list. |
inference_config
Required
|
An InferenceConfig object to configure the operation of the models. This must include an Environment object. |
generate_dockerfile
|
Whether to create a Dockerfile that can be run locally instead of building an image. Default value: False
|
auth_level
|
Auth level for the generated HTTP function. Default value: None
|
Returns
Type | Description |
---|---|
A ModelPackage object. |
Exceptions
Type | Description |
---|---|
Invalid trigger specified. |
package_service_bus_queue
Create an Azure Functions model package as a Docker image or Dockerfile with a service bus queue trigger.
package_service_bus_queue(workspace, models, inference_config, generate_dockerfile=False, input_queue_name=None, output_queue_name=None)
Parameters
Name | Description |
---|---|
workspace
Required
|
The workspace in which to create the package. |
models
Required
|
A list of Model objects to include in the package. Can be an empty list. |
inference_config
Required
|
An InferenceConfig object to configure the operation of the models. This must include an Environment object. |
generate_dockerfile
|
Whether to create a Dockerfile that can be run locally instead of building an image. Default value: False
|
input_queue_name
|
Input queue name for the queue trigger option. Default value: None
|
output_queue_name
|
Output queue name for the queue trigger option. Default value: None
|
Returns
Type | Description |
---|---|
A ModelPackage object. |
Exceptions
Type | Description |
---|---|
Invalid trigger specified. |