azure ml update service erro AttributeError: AttributeError: 'str' object has no attribute 'id'

Viewed 437

I am tying to update existing webservice using new Azure ML package Its failing with error - AttributeError: 'str' object has no attribute 'id'

"/opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/azureml/core/webservice/aks.py", line 678, in update

patch_list.append({'op': 'replace', 'path': '/imageId', 'value': image.id})

AttributeError: 'str' object has no attribute 'id'

Here is the script I am using -

ws = Workspace.get(
        name=workspace_name,
        subscription_id=subscription_id,
        resource_group=resource_group,
        auth=cli_auth)

model = Model.register(model_path = model_path,
                   model_name = model_name,
                   #tags = {"key": "1"},
                   description = model_description,
                   workspace = ws)

image_config = ContainerImage.image_configuration(execution_script="score.py", 
                                              runtime="python", 
                                              conda_file="packagesenv.yml")
image = 'testazureml'
service_name = 'testazureml'

# Retrieve existing service
service = Webservice(name = service_name, workspace = ws)

print(service)

service.update(image,'image.id')

please help I have been trying with different methods as - 'id', 'image_id' its still failing

2 Answers

This worked for me. above script was failing to get image details -

ws = Workspace.get(
    name=workspace_name,
    subscription_id=subscription_id,
    resource_group=resource_group,
    auth=cli_auth)

model = Model.register(model_path = model_path,
               model_name = model_name,
               #tags = {"key": "1"},
               description = model_description,
               workspace = ws)

image_config = ContainerImage.image_configuration(execution_script="score.py", 
                                          runtime="python", 
                                          conda_file="packagesenv.yml")
image = 'testazureml'
service_name = 'testazureml'

new_image = Image(ws, image)
# Retrieve existing service
service = Webservice(name = service_name, workspace = ws)

print(service)

service.update(image=new_image)

service.wait_for_deployment(show_output=True)
print(service.state)
Related