4
4
# IMPORTANT: Do not invoke this file directly. Please instead run eng/New-TestResources.ps1 from the repository root.
5
5
6
6
param (
7
- [hashtable ] $DeploymentOutputs
7
+ [hashtable ] $DeploymentOutputs ,
8
+
9
+ [Parameter ()]
10
+ [ValidatePattern (' ^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$' )]
11
+ [string ] $TestApplicationId ,
12
+
13
+ [Parameter ()]
14
+ [ValidatePattern (' ^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$' )]
15
+ [string ] $SubscriptionId ,
16
+
17
+ [Parameter (ValueFromRemainingArguments = $true )]
18
+ $RemoveTestResourcesRemainingArguments
8
19
)
9
20
10
21
# Outputs from the Bicep deployment passed in from New-TestResources
11
- $tenantId = $DeploymentOutputs [' MONITOR_TENANT_ID' ]
12
- $clientId = $DeploymentOutputs [' MONITOR_CLIENT_ID' ]
13
- $clientSecret = $DeploymentOutputs [' MONITOR_CLIENT_SECRET' ]
22
+ $tenantId = $DeploymentOutputs [' AZURE_MONITOR_TENANT_ID' ]
14
23
$dcrImmutableId = $DeploymentOutputs [' AZURE_MONITOR_DCR_ID' ]
15
24
$dceEndpoint = $DeploymentOutputs [' AZURE_MONITOR_DCE' ]
16
25
$streamName = $DeploymentOutputs [' AZURE_MONITOR_STREAM_NAME' ]
17
26
$environment = $DeploymentOutputs [' MONITOR_ENVIRONMENT' ]
18
- $authorityHost = $DeploymentOutputs [' AZURE_AUTHORITY_HOST' ]
19
27
20
28
# #################
21
29
# ## Step 0: Wait for role assignment to propagate
@@ -35,11 +43,16 @@ $audienceMappings = @{
35
43
36
44
$audience = $audienceMappings [$environment ]
37
45
38
- $scope = [System.Web.HttpUtility ]::UrlEncode(" $audience /.default" )
39
- $body = " client_id=$clientId &scope=$scope &client_secret=$clientSecret &grant_type=client_credentials" ;
40
- $headers = @ {" Content-Type" = " application/x-www-form-urlencoded" };
41
- $uri = " $authorityHost /$tenantId /oauth2/v2.0/token"
42
- $bearerToken = (Invoke-RestMethod - Uri $uri - Method " Post" - Body $body - Headers $headers ).access_token
46
+ az cloud set -- name $environment
47
+
48
+ if ($CI ) {
49
+ az login -- service- principal - u $TestApplicationId -- tenant $tenantId -- allow- no- subscriptions -- federated- token $env: ARM_OIDC_TOKEN
50
+ } else {
51
+ az login
52
+ }
53
+ az account set -- subscription $SubscriptionId
54
+
55
+ $bearerToken = az account get-access - token -- output json -- resource $audience | ConvertFrom-Json | Select-Object - ExpandProperty accessToken
43
56
44
57
# #################
45
58
# ## Step 2: Load up some sample data.
0 commit comments