メモ：AzureML ローカルエンドポイントを作成してローカルデプロイメントを作成すると取得できる情報はどう変わるのか

AzureMLでローカルエンドポイントを作成してローカルデプロイメントを作成すると取得できる情報はどう変わるのかメモします。

エンドポイントをローカルでデバッグする方法：
[Deploy machine learning models to managed online endpoint using Python SDK v2 (preview). - Azure Machine Learning | Microsoft Learn](https://learn.microsoft.com/en-us/azure/machine-learning/how-to-deploy-managed-online-endpoint-sdk-v2#create-local-endpoint-and-deployment)

Azure CLI version:
```bash
$ az version
{
  "azure-cli": "2.40.0",
  "azure-cli-core": "2.40.0",
  "azure-cli-telemetry": "1.0.8",
  "extensions": {
    "azure-iot": "0.17.1",
    "fzf": "1.0.2",
    "ml": "2.8.0",
    "spring-cloud": "3.1.5",
    "storage-preview": "0.8.3"
  }
}
```

## エンドポイントのみを作成した場合

```python
# Creating a local endpoint
import datetime

local_endpoint_name = "local-" + datetime.datetime.now().strftime("%m%d%H%M%f")

# create an online endpoint
endpoint = ManagedOnlineEndpoint(
    name=local_endpoint_name, description="this is a sample local endpoint"
)
```

取得結果 (CLI)：
```bash
$ az ml online-endpoint show -n local-10061534497697 --local
Field 'mirror_traffic': This is an experimental field, and may change at any time. Please see https://aka.ms/azuremlexperimental for more information.
{
  "auth_mode": "key",
  "description": "this is a sample local endpoint",
  "mirror_traffic": {},
  "name": "local-10061534497697",
  "properties": {},
  "tags": {},
  "traffic": {}
}
```

## デプロイメントの作成後
```python
model = Model(path="../model-1/model/sklearn_regression_model.pkl")
env = Environment(
    conda_file="../model-1/environment/conda.yml",
    image="mcr.microsoft.com/azureml/openmpi3.1.2-ubuntu18.04:20210727.v1",
)

blue_deployment = ManagedOnlineDeployment(
    name="blue",
    endpoint_name=local_endpoint_name,
    model=model,
    environment=env,
    code_configuration=CodeConfiguration(
        code="../model-1/onlinescoring", scoring_script="score.py"
    ),
    instance_type="Standard_F2s_v2",
    instance_count=1,
)

ml_client.online_deployments.begin_create_or_update(
    deployment=blue_deployment, local=True
)
```

取得結果 (CLI):
```bash
$  az ml online-endpoint show -n local-10061534497697 --local
Field 'mirror_traffic': This is an experimental field, and may change at any time. Please see https://aka.ms/azuremlexperimental for more information.
{
  "auth_mode": "key",
  "description": "this is a sample local endpoint",
  "location": "local",
  "mirror_traffic": {},
  "name": "local-10061534497697",
  "properties": {},
  "provisioning_state": "Succeeded",
  "scoring_uri": "http://localhost:49155/score",
  "tags": {},
  "traffic": {}
}
```

取得結果 (SDK)
```python
ml_client.online_endpoints.get(local_endpoint_name,local=True)
```

```python
ManagedOnlineEndpoint({'public_network_access': None, 'provisioning_state': 'Succeeded', 'scoring_uri': 'http://localhost:49155/score', 'swagger_uri': None, 'name': 'local-10061534497697', 'description': 'this is a sample local endpoint', 'tags': {}, 'properties': {}, 'id': None, 'Resource__source_path': None, 'base_path': '/home/aical/working_directory/managed_online_endpoints', 'creation_context': None, 'serialize': <msrest.serialization.Serializer object at 0x7ffb781811c0>, 'auth_mode': 'key', 'location': 'local', 'identity': None, 'traffic': {}, 'mirror_traffic': {}, 'kind': None})
```

CLIの方が見やすいが、SDKの方には`base_path`が入っているので、少し出てくるものは違うっぽい。エンドポイント・デプロイメントに関しては同じかな。