2

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

megha
  • 621
  • 2
  • 11
  • 36

2 Answers2

0

Here is Sample to Register and Deploy.

Document to Update a deployed web service: https://learn.microsoft.com/en-us/azure/machine-learning/how-to-deploy-update-web-service

Ram
  • 2,459
  • 1
  • 7
  • 14
  • This shows error - unable to use Environment object to update Webservice created with Image object – megha Jul 22 '21 at 02:34
  • Can you please add more details about the error. – Ram Jul 22 '21 at 04:40
  • can you please help with this - https://stackoverflow.com/questions/68505595/failing-to-create-image-in-azure-ml-workspace – megha Jul 23 '21 at 22:31
0

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)
megha
  • 621
  • 2
  • 11
  • 36