Skip to content

Commit af2ed74

Browse files
Extract IMDS api-version into a constant
Move the IMDS compute metadata api-version into a module-level _IMDS_API_VERSION constant so future version bumps are a single, self-documenting change, consistent with msal-go and msal-java. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ed5f422 commit af2ed74

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

msal/region.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
_VALID_REGION_RE = re.compile(r"^[a-z][a-z0-9-]*$")
99

10+
# IMDS compute metadata API version used for region auto-discovery.
11+
# Bump this single constant when moving to a newer IMDS API version.
12+
_IMDS_API_VERSION = "2021-02-01"
13+
1014

1115
def _validate_region(region, source="unknown"):
1216
"""Return *region* unchanged if it looks like a valid Azure region name,
@@ -35,7 +39,7 @@ def _detect_region_of_azure_vm(http_client):
3539

3640
# The region is read from the "location" field of the compute metadata.
3741
# https://learn.microsoft.com/en-us/azure/virtual-machines/instance-metadata-service?tabs=linux#response-1
38-
"?api-version=2021-02-01"
42+
"?api-version=" + _IMDS_API_VERSION
3943
)
4044
logger.info(
4145
"Connecting to IMDS {}. "

0 commit comments

Comments
 (0)