Skip to content

Commit 42d7ab4

Browse files
marossetjjyao
authored andcommitted
[Core] [Azure] Use subscription id from azure profile if not provided in config during AzureNodeProvider init (ray-project#56640)
Signed-off-by: Mark Rossett <[email protected]> Co-authored-by: Jiajun Yao <[email protected]> Signed-off-by: Seiji Eicher <[email protected]>
1 parent a19ed71 commit 42d7ab4

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

python/ray/autoscaler/_private/_azure/node_provider.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from typing import List, Optional
88
from uuid import uuid4
99

10+
from azure.common.credentials import get_cli_profile
1011
from azure.core.exceptions import ResourceNotFoundError
1112
from azure.identity import DefaultAzureCredential
1213
from azure.mgmt.compute import ComputeManagementClient
@@ -66,7 +67,16 @@ class AzureNodeProvider(NodeProvider):
6667

6768
def __init__(self, provider_config, cluster_name):
6869
NodeProvider.__init__(self, provider_config, cluster_name)
69-
subscription_id = provider_config["subscription_id"]
70+
subscription_id = provider_config.get("subscription_id")
71+
if subscription_id is None:
72+
# Get subscription from logged in azure profile
73+
# if it isn't provided in the provider_config
74+
# so operations like `get-head-ip` will work
75+
subscription_id = get_cli_profile().get_subscription_id()
76+
logger.info(
77+
"subscription_id not found in provider config, falling back "
78+
f"to subscription_id from the logged in azure profile: {subscription_id}"
79+
)
7080
self.cache_stopped_nodes = provider_config.get("cache_stopped_nodes", True)
7181
credential = DefaultAzureCredential(exclude_shared_token_cache_credential=True)
7282
self.compute_client = ComputeManagementClient(credential, subscription_id)

0 commit comments

Comments
 (0)