Skip to content

Commit d644766

Browse files
committed
[Core] [Azure] Use subscription id from azure profile if not provided in config during AzureNodeProvider init
Signed-off-by: Mark Rossett <[email protected]>
1 parent 212367d commit d644766

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from threading import RLock
77
from uuid import uuid4
88

9+
from azure.common.credentials import get_cli_profile
910
from azure.core.exceptions import ResourceNotFoundError
1011
from azure.identity import DefaultAzureCredential
1112
from azure.mgmt.compute import ComputeManagementClient
@@ -65,6 +66,17 @@ class AzureNodeProvider(NodeProvider):
6566

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

0 commit comments

Comments
 (0)