AciWebservice Class
Represents a machine learning model deployed as a web service endpoint on Azure Container Instances.
A deployed service is created from a model, script, and associated files. The resulting web service is a load-balanced, HTTP endpoint with a REST API. You can send data to this API and receive the prediction returned by the model.
For more information, see Deploy a model to Azure Container Instances.
Initialize the Webservice instance.
The Webservice constructor retrieves a cloud representation of a Webservice object associated with the provided workspace. It will return an instance of a child class corresponding to the specific type of the retrieved Webservice object.
- Inheritance
-
AciWebservice
Constructor
AciWebservice(workspace, name)
Parameters
Remarks
The recommended deployment pattern is to create a deployment configuration object with the
deploy_configuration
method and then use it with the deploy
method of the
Model class as shown below.
from azureml.core.model import InferenceConfig
from azureml.core.webservice import AciWebservice
service_name = 'my-custom-env-service'
inference_config = InferenceConfig(entry_script='score.py', environment=environment)
aci_config = AciWebservice.deploy_configuration(cpu_cores=1, memory_gb=1)
service = Model.deploy(workspace=ws,
name=service_name,
models=[model],
inference_config=inference_config,
deployment_config=aci_config,
overwrite=True)
service.wait_for_deployment(show_output=True)
There are a number of ways to deploy a model as a webservice, including with the:
deploy
method of the Model for models already registered in the workspace.deploy_from_image
method of Webservice.deploy_from_model
method of Webservice for models already registered in the workspace. This method will create an image.deploy
method of the Webservice, which will register a model and create an image.
For information on working with webservices, see
The Variables section lists attributes of a local representation of the cloud AciWebservice object. These variables should be considered read-only. Changing their values will not be reflected in the corresponding cloud object.
Variables
- enable_app_insights
- bool
Whether or not AppInsights logging is enabled for the Webservice.
- cname
- str
The cname for the Webservice.
- container_resource_requirements
- ContainerResourceRequirements
The container resource requirements for the Webservice.
- encryption_properties
- EncryptionProperties
The encryption properties for the Webservice.
- vnet_configuration
- VnetConfiguration
The virtual network properties for the Webservice, configuration should be created and provided by user.
- azureml.core.webservice.AciWebservice.location
- str
The location the Webservice is deployed to.
- public_ip
- str
The public ip address of the Webservice.
- azureml.core.webservice.AciWebservice.scoring_uri
- str
The scoring endpoint for the Webservice
- ssl_enabled
- bool
Whether or not SSL is enabled for the Webservice
- public_fqdn
- str
The public FQDN for the Webservice
- environment
- Environment
The Environment object that was used to create the Webservice
A list of Models deployed to the Webservice
- azureml.core.webservice.AciWebservice.swagger_uri
- str
The swagger endpoint for the Webservice
Methods
add_properties |
Add key value pairs to this Webservice's properties dictionary. |
add_tags |
Add key value pairs to this Webservice's tags dictionary. |
deploy_configuration |
Create a configuration object for deploying an AciWebservice. |
get_token |
Retrieve auth token for this Webservice, scoped to the current user. Note Not implemented. |
remove_tags |
Remove the specified keys from this Webservice's dictionary of tags. |
run |
Call this Webservice with the provided input. |
serialize |
Convert this Webservice into a JSON serialized dictionary. |
update |
Update the Webservice with provided properties. Values left as None will remain unchanged in this Webservice. |
add_properties
Add key value pairs to this Webservice's properties dictionary.
add_properties(properties)
Parameters
add_tags
Add key value pairs to this Webservice's tags dictionary.
add_tags(tags)
Parameters
Exceptions
deploy_configuration
Create a configuration object for deploying an AciWebservice.
static deploy_configuration(cpu_cores=None, memory_gb=None, tags=None, properties=None, description=None, location=None, auth_enabled=None, ssl_enabled=None, enable_app_insights=None, ssl_cert_pem_file=None, ssl_key_pem_file=None, ssl_cname=None, dns_name_label=None, primary_key=None, secondary_key=None, collect_model_data=None, cmk_vault_base_url=None, cmk_key_name=None, cmk_key_version=None, vnet_name=None, subnet_name=None)
Parameters
- cpu_cores
- float
The number of CPU cores to allocate for this Webservice. Can be a decimal. Defaults to 0.1
- memory_gb
- float
The amount of memory (in GB) to allocate for this Webservice. Can be a decimal. Defaults to 0.5
A dictionary of key value properties to give this Webservice. These properties cannot be changed after deployment, however new key value pairs can be added.
- location
- str
The Azure region to deploy this Webservice to. If not specified the Workspace location will be used. For more details on available regions, see Products by region.
- auth_enabled
- bool
Whether or not to enable auth for this Webservice. Defaults to False.
- ssl_enabled
- bool
Whether or not to enable SSL for this Webservice. Defaults to False.
- enable_app_insights
- bool
Whether or not to enable AppInsights for this Webservice. Defaults to False.
- dns_name_label
- str
The DNS name label for the scoring endpoint. If not specified a unique DNS name label will be generated for the scoring endpoint.
- collect_model_data
- bool
Whether or not to enabled model data collection for the Webservice.
Returns
A configuration object to use when deploying a Webservice object.
Return type
Exceptions
get_token
Retrieve auth token for this Webservice, scoped to the current user.
Note
Not implemented.
get_token()
Returns
The auth token for this Webservice and when it should be refreshed after.
Return type
Exceptions
remove_tags
Remove the specified keys from this Webservice's dictionary of tags.
remove_tags(tags)
Parameters
run
Call this Webservice with the provided input.
run(input_data)
Parameters
- input_data
- <xref:varies>
The input to call the Webservice with.
Returns
The result of calling the Webservice.
Return type
Exceptions
serialize
Convert this Webservice into a JSON serialized dictionary.
serialize()
Returns
The JSON representation of this Webservice object.
Return type
update
Update the Webservice with provided properties.
Values left as None will remain unchanged in this Webservice.
update(image=None, tags=None, properties=None, description=None, auth_enabled=None, ssl_enabled=None, ssl_cert_pem_file=None, ssl_key_pem_file=None, ssl_cname=None, enable_app_insights=None, models=None, inference_config=None)
Parameters
A dictionary of key value tags to give this Webservice. Will replace existing tags.
A dictionary of key value properties to add to existing properties dictionary.
- enable_app_insights
- bool
Whether or not to enable AppInsights for this Webservice.
- inference_config
- InferenceConfig
An InferenceConfig object used to provide the required model deployment properties.
Return type
Feedback
Submit and view feedback for