Пример #1
0
# Show output of the deployment on stdout
dev_service.wait_for_deployment(show_output=True)
print("State of Service: {}".format(dev_service.state))

# Checking status of web service
print("Checking status of ACI Dev Deployment")
if dev_service.state != "Healthy":
    raise Exception(
        "Dev Deployment on ACI failed with the following status: {} and logs: \n{}"
        .format(dev_service.state, dev_service.get_logs()))

# Testing ACI web service
print("Testing ACI web service")
test_sample = test_functions.get_test_data_sample()
print("Test Sample: ", test_sample)
test_sample_encoded = bytes(test_sample, encoding='utf8')
try:
    prediction = dev_service.run(input_data=test_sample)
    print(prediction)
except Exception as e:
    result = str(e)
    logs = dev_service.get_logs()
    dev_service.delete()
    raise Exception(
        "ACI Dev web service is not working as expected: \n{} \nLogs: \n{}".
        format(result, logs))

# Delete aci after test
print("Deleting ACI Dev web service after successful test")
dev_service.delete()
Пример #2
0
print('{}(v.{} [{}]) stored at {} with build log {}'.format(
    image.name, image.version, image.creation_state, image.image_location,
    image.image_build_log_uri))

aciconfig = AciWebservice.deploy_configuration(
    cpu_cores=1,
    memory_gb=1,
    tags={'area': "visual object classificiation"},
    description='A sample description')

aci_service_name = 'aciwebservice' + datetime.datetime.now().strftime('%m%d%H')

try:
    service = AciWebservice(ws, aci_service_name)
    service.delete()
except Exception as e:
    print(e)
    pass

service = Webservice.deploy_from_image(deployment_config=aciconfig,
                                       image=image,
                                       name=aci_service_name,
                                       workspace=ws)

service.wait_for_deployment()

# print(service.get_logs())

print('Deployed ACI Webservice: {} \nWebservice Uri: {}'.format(
    service.name, service.scoring_uri))