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
A list of Model objects to include in the package. Can be an empty list.
- inference_config
- InferenceConfig
An InferenceConfig object to configure the operation of the models. This must include an Environment object.
- generate_dockerfile
- bool
Whether to create a Dockerfile that can be run locally instead of building an image.
- functions_enabled
- bool
Whether Azure Functions should be enabled in the packaged container.
- trigger
- str
An optional trigger for the function. The values can be "blob", "http", or "service_bus_queue".
- kwargs
Any of the arguments for a specific package function defined in this module. For example,
for the package_http
method, the argument passed is auth_level
.
Returns
A ModelPackage object.
Return type
Exceptions
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
A list of Model objects to include in the package. Can be an empty list.
- inference_config
- InferenceConfig
An InferenceConfig object to configure the operation of the models. This must include an Environment object.
- generate_dockerfile
- bool
Whether to create a Dockerfile that can be run locally instead of building an image.
Returns
A ModelPackage object.
Return type
Exceptions
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
A list of Model objects to include in the package. Can be an empty list.
- inference_config
- InferenceConfig
An InferenceConfig object to configure the operation of the models. This must include an Environment object.
- generate_dockerfile
- bool
Whether to create a Dockerfile that can be run locally instead of building an image.
Returns
A ModelPackage object.
Return type
Exceptions
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
A list of Model objects to include in the package. Can be an empty list.
- inference_config
- InferenceConfig
An InferenceConfig object to configure the operation of the models. This must include an Environment object.
- generate_dockerfile
- bool
Whether to create a Dockerfile that can be run locally instead of building an image.
Returns
A ModelPackage object.
Return type
Exceptions
Invalid trigger specified.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for