Image Class

Defines the abstract parent class for Azure Machine Learning Images.

This class is DEPRECATED. Use the Environment class instead.

Image constructor.

This class is DEPRECATED. Use the Environment class instead.

Image constructor is used to retrieve a cloud representation of a Image object associated with the provided workspace. Will return an instance of a child class corresponding to the specific type of the retrieved Image object.

Inheritance
Image

Constructor

Image(workspace, name=None, id=None, tags=None, properties=None, version=None)

Parameters

Name Description
workspace
Required

The Workspace object containing the Image to retrieve.

name
str

The name of the Image to retrieve. Will return the latest version of the Image, if it exists.

default value: None
id
str

The specific ID of the Image to retrieve. (ID is "<name>:<version>")

default value: None
tags

Will filter Image results based on the provided list, by either 'key' or '[key, value]'. Ex. ['key', ['key2', 'key2 value']]

default value: None
properties

Will filter Image results based on the provided list, by either 'key' or '[key, value]'. Ex. ['key', ['key2', 'key2 value']]

default value: None
version
str

When version and name are both specified, will return the specific version of the Image.

default value: None
workspace
Required

The workspace object containing the Image to retrieve

name
Required
str

The name of the Image to retrieve. Will return the latest version, if it exists

id
Required
str

The specific ID of the Image to retrieve. (ID is ":")

tags
Required

Will filter Image results based on the provided list, by either 'key' or '[key, value]'. Ex. ['key', ['key2', 'key2 value']]

properties
Required

Will filter Image results based on the provided list, by either 'key' or '[key, value]'. Ex. ['key', ['key2', 'key2 value']]

version
Required
str

When version and name are both specified, will return the specific version of the Image.

Remarks

The Image constructor retrieves a cloud representation of an Image object associated with the provided workspace. It returns an instance of a child class corresponding to the specific type of the retrieved Image object.

An Image object is used to deploy a user's Model as a Webservice. The Image object typically contains a Model, an execution script, and any dependencies needed for Model deployment. The Image class has multiple subclasses such as ContainerImage for Docker Images, and Images like FPGA.

See the ContainerImage class for an example of a class that inherits from the Image class.

Images are typically used in workflows that require using an image. For most workflows, you should instead use the Environment class to define your image. Then you can use the Environment object with the Model deploy() method to deploy the model as a web service. You can also use the Model package() method to create an image that can be downloaded to your local Docker install as an image or as a Dockerfile.

See the following link for an overview on deploying models in Azure: https://aka.ms/azureml-how-deploy.

Methods

add_properties

Add properties to the image.

add_tags

Add tags to the image.

create

Create an image in the provided workspace.

delete

Delete an image from its corresponding workspace.

deserialize

Convert a json object into a Image object.

image_configuration

Abstract method for creating an image configuration object.

list

List the Images associated with the corresponding workspace. Can be filtered with specific parameters.

remove_tags

Remove tags from the image.

serialize

Convert this Image object into a JSON serialized dictionary.

update

Update the image.

update_creation_state

Refresh the current state of the in-memory object.

Perform an in-place update of the properties of the object based on the current state of the corresponding cloud object. Primarily useful for manual polling of creation state.

wait_for_creation

Wait for the image to finish creating.

Wait for image creation to reach a terminal state. Will throw a WebserviceException if it reaches a non-successful terminal state.

add_properties

Add properties to the image.

add_properties(properties)

Parameters

Name Description
properties
Required

A dictionary of properties to add.

Exceptions

Type Description

add_tags

Add tags to the image.

add_tags(tags)

Parameters

Name Description
tags
Required

A dictionary of tags to add.

Exceptions

Type Description

create

Create an image in the provided workspace.

static create(workspace, name, models, image_config)

Parameters

Name Description
workspace
Required
<xref:<xref:workspace: azureml.core.workspace.Workspace>>

The workspace to associate with this image.

name
Required
str

The name to associate with this image.

models
Required

A list of Model objects to package with this image. Can be an empty list.

image_config
Required

The image config object to use to configure this image.

Returns

Type Description

The created Image object.

Exceptions

Type Description

delete

Delete an image from its corresponding workspace.

delete()

Exceptions

Type Description

Remarks

This method fails if the image has been deployed to a live webservice.

deserialize

Convert a json object into a Image object.

deserialize(workspace, image_payload)

Parameters

Name Description
cls
Required

Indicates class method.

workspace
Required

The workspace object the Image is registered under.

image_payload
Required

A JSON object to convert to a Image object.

Returns

Type Description

The Image representation of the provided JSON object.

Exceptions

Type Description

Remarks

This method fails if the provided workspace is not the workspace the image is registered under.

image_configuration

Abstract method for creating an image configuration object.

abstract static image_configuration()

Exceptions

Type Description

list

List the Images associated with the corresponding workspace. Can be filtered with specific parameters.

static list(workspace, image_name=None, model_name=None, model_id=None, tags=None, properties=None)

Parameters

Name Description
workspace
Required

The Workspace object to list the Images in.

image_name
str

Filter list to only include Images deployed with the specific image name.

default value: None
model_name
str

Filter list to only include Images deployed with the specific model name.

default value: None
model_id
str

Filter list to only include Images deployed with the specific model ID.

default value: None
tags

Will filter based on the provided list, by either 'key' or '[key, value]'. Ex. ['key', ['key2', 'key2 value']]

default value: None
properties

Will filter based on the provided list, by either 'key' or '[key, value]'. Ex. ['key', ['key2', 'key2 value']]

default value: None

Returns

Type Description
list[<xref:Images>]

A filtered list of Images in the provided workspace.

Exceptions

Type Description

remove_tags

Remove tags from the image.

remove_tags(tags)

Parameters

Name Description
tags
Required

A list of keys corresponding to tags to be removed.

Exceptions

Type Description

serialize

Convert this Image object into a JSON serialized dictionary.

serialize()

Returns

Type Description

The JSON representation of this Image object.

Exceptions

Type Description

update

Update the image.

update(tags)

Parameters

Name Description
tags
Required

A dictionary of tags to update the image with. Will overwrite any existing tags.

Exceptions

Type Description

update_creation_state

Refresh the current state of the in-memory object.

Perform an in-place update of the properties of the object based on the current state of the corresponding cloud object. Primarily useful for manual polling of creation state.

update_creation_state()

Exceptions

Type Description

wait_for_creation

Wait for the image to finish creating.

Wait for image creation to reach a terminal state. Will throw a WebserviceException if it reaches a non-successful terminal state.

wait_for_creation(show_output=False)

Parameters

Name Description
show_output

Boolean option to print more verbose output. Defaults to False.

default value: False

Exceptions

Type Description