Exemplo n.º 1
0
    def list_deployments(self):
        """
        List deployments.

        :return: A list of dicts corresponding to deployments.
        """
        try:
            service_list = []
            services = Webservice.list(self.workspace)
            for service in services:
                service_list.append(service.serialize())
            return service_list
        except WebserviceException as e:
            raise MlflowException(
                'There was an error listing deployments: \n{}'.format(
                    e.message)) from e
import requests
import json
from azureml.core import Webservice
from azureml.core import Workspace

# URL for the web service
scoring_uri = 'http://97d4b24f-8f41-46e7-b875-32d30bfb8deb.westus2.azurecontainer.io/score'
ws = Workspace.get('Mohith_workspace',
                   auth=None,
                   subscription_id='c229fecc-7c30-489c-b79f-1de37cd2de58',
                   resource_group='Mohith_group')
print(ws)

services = Webservice.list(ws)
print(services)
print(services[0].scoring_uri)
print(services[0].swagger_uri)

service = services[0]
print(service)

# Set the content type
headers = {'Content-Type': 'application/json'}

if service.auth_enabled:
    headers['Authorization'] = 'Bearer ' + service.get_keys()[0]
elif service.token_auth_enabled:
    headers['Authorization'] = 'Bearer ' + service.get_token()[0]
# If the service is authenticated, set the key or token
key = service.get_keys()[0]