Skip to content

Commit eecf802

Browse files
authored
[App Service] az webapp deploy: Change get_bearer_token to use App Service Audience (#31988)
1 parent ca880ae commit eecf802

File tree

2 files changed

+12
-1
lines changed
  • src
    • azure-cli-core/azure/cli/core
    • azure-cli/azure/cli/command_modules/appservice

2 files changed

+12
-1
lines changed

src/azure-cli-core/azure/cli/core/cloud.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class CloudEndpoints: # pylint: disable=too-few-public-methods,too-many-instanc
6666
"active_directory_resource_id": "authentication.audiences[0]",
6767
"app_insights_resource_id": "appInsightsResourceId",
6868
"app_insights_telemetry_channel_resource_id": "appInsightsTelemetryChannelResourceId",
69+
"app_service_resource_id": "appServiceResourceId",
6970
"attestation_resource_id": "attestationResourceId",
7071
"azmirror_storage_account_resource_id": "azmirrorStorageAccountResourceId",
7172
"batch_resource_id": "batch",
@@ -89,6 +90,7 @@ def __init__(self, # pylint: disable=unused-argument
8990
active_directory_resource_id=None,
9091
app_insights_resource_id=None,
9192
app_insights_telemetry_channel_resource_id=None,
93+
app_service_resource_id=None,
9294
attestation_resource_id=None,
9395
azmirror_storage_account_resource_id=None,
9496
batch_resource_id=None,
@@ -111,6 +113,7 @@ def __init__(self, # pylint: disable=unused-argument
111113
self.active_directory_resource_id = active_directory_resource_id
112114
self.app_insights_resource_id = app_insights_resource_id
113115
self.app_insights_telemetry_channel_resource_id = app_insights_telemetry_channel_resource_id
116+
self.app_service_resource_id = app_service_resource_id
114117
self.attestation_resource_id = attestation_resource_id
115118
self.azmirror_storage_account_resource_id = azmirror_storage_account_resource_id
116119
self.batch_resource_id = batch_resource_id
@@ -272,6 +275,7 @@ def _arm_to_cli_mapper(arm_dict):
272275
fallback_value=get_endpoint_fallback_value('app_insights_resource_id')),
273276
app_insights_telemetry_channel_resource_id=get_endpoint('appInsightsTelemetryChannelResourceId',
274277
fallback_value=get_endpoint_fallback_value('app_insights_telemetry_channel_resource_id')),
278+
app_service_resource_id=get_endpoint('appServiceResourceId', fallback_value=get_endpoint_fallback_value('app_service_resource_id')),
275279
attestation_resource_id=get_endpoint('attestationResourceId',
276280
fallback_value=get_endpoint_fallback_value('attestation_resource_id')),
277281
azmirror_storage_account_resource_id=get_endpoint('azmirrorStorageAccountResourceId'),
@@ -377,6 +381,7 @@ class CloudNameEnum: # pylint: disable=too-few-public-methods
377381
app_insights_telemetry_channel_resource_id='https://dc.applicationinsights.azure.com/v2/track',
378382
synapse_analytics_resource_id='https://dev.azuresynapse.net',
379383
attestation_resource_id='https://attest.azure.net',
384+
app_service_resource_id='https://appservice.azure.com',
380385
portal='https://portal.azure.com'),
381386
suffixes=CloudSuffixes(
382387
storage_endpoint='core.windows.net',
@@ -412,6 +417,9 @@ class CloudNameEnum: # pylint: disable=too-few-public-methods
412417
log_analytics_resource_id='https://api.loganalytics.azure.cn',
413418
app_insights_telemetry_channel_resource_id='https://dc.applicationinsights.azure.cn/v2/track',
414419
synapse_analytics_resource_id='https://dev.azuresynapse.azure.cn',
420+
# App Service Audience is currently not available in Mooncake,
421+
# Using the management endpoint until the App Service audience is enabled
422+
app_service_resource_id='https://management.core.chinacloudapi.cn/',
415423
portal='https://portal.azure.cn'),
416424
suffixes=CloudSuffixes(
417425
storage_endpoint='core.chinacloudapi.cn',
@@ -443,6 +451,9 @@ class CloudNameEnum: # pylint: disable=too-few-public-methods
443451
log_analytics_resource_id='https://api.loganalytics.us',
444452
app_insights_telemetry_channel_resource_id='https://dc.applicationinsights.us/v2/track',
445453
synapse_analytics_resource_id='https://dev.azuresynapse.usgovcloudapi.net',
454+
# App Service Audience is currently not available in US Government cloud,
455+
# Using the management endpoint until the App Service audience is enabled
456+
app_service_resource_id='https://management.core.usgovcloudapi.net/',
446457
portal='https://portal.azure.us'),
447458
suffixes=CloudSuffixes(
448459
storage_endpoint='core.usgovcloudapi.net',

src/azure-cli/azure/cli/command_modules/appservice/custom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4803,7 +4803,7 @@ def get_bearer_token(cli_ctx):
48034803
from azure.cli.core.auth.util import resource_to_scopes
48044804
profile = Profile(cli_ctx=cli_ctx)
48054805
credential, _, _ = profile.get_login_credentials()
4806-
scopes = resource_to_scopes(cli_ctx.cloud.endpoints.active_directory_resource_id)
4806+
scopes = resource_to_scopes(cli_ctx.cloud.endpoints.app_service_resource_id)
48074807
bearer_token = credential.get_token(*scopes).token
48084808
return bearer_token
48094809

0 commit comments

Comments
 (0)