示例#1
0
myenv.python.conda_dependencies.add_channel("conda-forge")
myenv.spark.packages = [
    SparkPackage("com.microsoft.ml.spark", "mmlspark_2.11", "0.15"),
    SparkPackage("com.microsoft.azure", "azure-storage", "2.0.0"),
    SparkPackage("org.apache.hadoop", "hadoop-azure", "2.7.0")
]
myenv.spark.repositories = ["https://mmlspark.azureedge.net/maven"]
inference_config = InferenceConfig(entry_script='scoreSpark.py',
                                   environment=myenv)

deployment_config = AksWebservice.deploy_configuration(
    auth_enabled=False,
    collect_model_data=True,
    enable_app_insights=True,
    cpu_cores=2,
    memory_gb=2)
aks_target = AksCompute(ws, aks_name)

service = Model.deploy(ws, service_name, [model], inference_config,
                       deployment_config, aks_target)
service.wait_for_deployment(show_output=True)

print(service.state)
print(service.scoring_uri)

aks_webservice = {}
aks_webservice['aks_name'] = service.name
aks_webservice['aks_url'] = service.scoring_uri
with open('../conf/' + service_name + '.json', 'w') as outfile:
    json.dump(aks_webservice, outfile)
示例#2
0
#deploy, here to container instance
from azureml.core.webservice import AciWebservice
from azureml.core.model import InferenceConfig

# Configure the scoring environment
inference_config = InferenceConfig(runtime= "python",
                                   entry_script=script_file,
                                   conda_file=env_file)

deployment_config = AciWebservice.deploy_configuration(cpu_cores = 1, memory_gb = 1)

service_name = "diabetes-service"

service = Model.deploy(ws, service_name, [model], inference_config, deployment_config)

service.wait_for_deployment(True)
print(service.state)


#check status
print(service.state)
print(service.get_logs())

# If you need to make a change and redeploy, you may need to delete unhealthy service using the following code:
#service.delete()

#get names of web services in ws
for webservice_name in ws.webservices:
    print(webservice_name)