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.

Inheritance
AciWebservice

Constructor

AciWebservice(workspace, name)

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)

Full sample is available from https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/deployment/deploy-to-cloud/model-register-and-deploy.ipynb

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

azureml.core.webservice.AciWebservice.models
list[Model]

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

properties
dict[str, str]

The dictionary of properties to add.

add_tags

Add key value pairs to this Webservice's tags dictionary.

add_tags(tags)

Parameters

tags
dict[str, str]

The dictionary of tags to add.

Exceptions

deploy_configuration

Create a configuration object for deploying an AciWebservice.

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
default value: None

The number of CPU cores to allocate for this Webservice. Can be a decimal. Defaults to 0.1

memory_gb
float
default value: None

The amount of memory (in GB) to allocate for this Webservice. Can be a decimal. Defaults to 0.5

tags
dict[str, str]
default value: None

A dictionary of key value tags to give this Webservice.

properties
dict[str, str]
default value: None

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.

description
str
default value: None

A description to give this Webservice.

location
str
default value: None

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
default value: None

Whether or not to enable auth for this Webservice. Defaults to False.

ssl_enabled
bool
default value: None

Whether or not to enable SSL for this Webservice. Defaults to False.

enable_app_insights
bool
default value: None

Whether or not to enable AppInsights for this Webservice. Defaults to False.

ssl_cert_pem_file
str
default value: None

The cert file needed if SSL is enabled.

ssl_key_pem_file
str
default value: None

The key file needed if SSL is enabled.

ssl_cname
str
default value: None

The cname for if SSL is enabled.

dns_name_label
str
default value: None

The DNS name label for the scoring endpoint. If not specified a unique DNS name label will be generated for the scoring endpoint.

primary_key
str
default value: None

A primary auth key to use for this Webservice.

secondary_key
str
default value: None

A secondary auth key to use for this Webservice.

collect_model_data
bool
default value: None

Whether or not to enabled model data collection for the Webservice.

cmk_vault_base_url
str
default value: None

customer managed key vault base url

cmk_key_name
str
default value: None

customer managed key name.

cmk_key_version
str
default value: None

customer managed key version.

vnet_name
str
default value: None

virtual network name.

subnet_name
str
default value: None

subnet name within virtual network.

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

remove_tags

Remove the specified keys from this Webservice's dictionary of tags.

remove_tags(tags)

Parameters

tags
list[str]

The list of keys to remove.

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

image
Image
default value: None

A new Image to deploy to the Webservice.

tags
dict[str, str]
default value: None

A dictionary of key value tags to give this Webservice. Will replace existing tags.

properties
dict[str, str]
default value: None

A dictionary of key value properties to add to existing properties dictionary.

description
str
default value: None

A description to give this Webservice.

auth_enabled
bool
default value: None

Enable or disable auth for this Webservice.

ssl_enabled
bool
default value: None

Whether or not to enable SSL for this Webservice.

ssl_cert_pem_file
str
default value: None

The cert file needed if SSL is enabled.

ssl_key_pem_file
str
default value: None

The key file needed if SSL is enabled.

ssl_cname
str
default value: None

The cname for if SSL is enabled.

enable_app_insights
bool
default value: None

Whether or not to enable AppInsights for this Webservice.

models
list[Model]
default value: None

A list of Model objects to package into the updated service.

inference_config
InferenceConfig
default value: None

An InferenceConfig object used to provide the required model deployment properties.

Return type