Skip to content

Commit 2f534e9

Browse files
issacnitinmsftmbrancatoMike Brancato
authored
M168: Support for Azure Management Group in Azure CLI V2 task (#12922) (#12946)
* Support Azure CLI login for AzureAD and Azure DevOps (#12516) * Support Azure CLI login for AzureAD and Azure DevOps * Set subscription only if parameter is set * Increment task version Co-authored-by: Mike Brancato <[email protected]> Co-authored-by: Nitin Issac Joy <[email protected]> * Support for Azure Management Group in Azure CLI V2 task (#12922) * Support for management group in Azure CLI * Updating text * Review comments * Updating task version Co-authored-by: Mike Brancato <[email protected]> Co-authored-by: Mike Brancato <[email protected]>
1 parent e35faa6 commit 2f534e9

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

Tasks/AzureCLIV2/Strings/resources.resjson/en-US/resources.resjson

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"loc.instanceNameFormat": "Azure CLI $(scriptPath)",
66
"loc.releaseNotes": "What's new in Version 2.0:\n- Support for PowerShell and PowerShell Core script. \n- PowerShell Core works with cross-platform agents (Linux, macOS, or Windows), make sure the agent has PowerShell version 6 or more. \n- Powershell script works with only Windows agent, make sure the agent has PowerShell version 5 or below.",
77
"loc.group.displayName.advanced": "Advanced",
8-
"loc.input.label.connectedServiceNameARM": "Azure subscription",
9-
"loc.input.help.connectedServiceNameARM": "Select an Azure resource manager subscription for the deployment",
8+
"loc.input.label.connectedServiceNameARM": "Azure Resource Manager connection",
9+
"loc.input.help.connectedServiceNameARM": "Select an Azure Resource Manager service connection for the deployment",
1010
"loc.input.label.scriptType": "Script Type",
1111
"loc.input.help.scriptType": "Type of script: PowerShell/PowerShell Core/Bat/Shell script. Select Shell/PowerShell Core script when running on Linux agent or Batch/PowerShell/PowerShell Core script when running on Windows agent. PowerShell Core script can run on cross-platform agents (Linux, macOS, or Windows).",
1212
"loc.input.label.scriptLocation": "Script Location",

Tasks/AzureCLIV2/azureclitask.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export class azureclitask {
134134
let escapedCliPassword = cliPassword.replace(/"/g, '\\"');
135135
tl.setSecret(escapedCliPassword.replace(/\\/g, '\"'));
136136
//login using svn
137-
Utility.throwIfError(tl.execSync("az", `login --service-principal -u "${servicePrincipalId}" -p "${escapedCliPassword}" --tenant "${tenantId}"`), tl.loc("LoginFailed"));
137+
Utility.throwIfError(tl.execSync("az", `login --service-principal -u "${servicePrincipalId}" -p "${escapedCliPassword}" --tenant "${tenantId}" --allow-no-subscriptions`), tl.loc("LoginFailed"));
138138
}
139139
else if(authScheme.toLowerCase() == "managedserviceidentity") {
140140
//login using msi
@@ -145,8 +145,10 @@ export class azureclitask {
145145
}
146146

147147
this.isLoggedIn = true;
148-
//set the subscription imported to the current subscription
149-
Utility.throwIfError(tl.execSync("az", "account set --subscription \"" + subscriptionID + "\""), tl.loc("ErrorInSettingUpSubscription"));
148+
if(!!subscriptionID) {
149+
//set the subscription imported to the current subscription
150+
Utility.throwIfError(tl.execSync("az", "account set --subscription \"" + subscriptionID + "\""), tl.loc("ErrorInSettingUpSubscription"));
151+
}
150152
}
151153

152154
private static setConfigDirectory(): void {
@@ -189,4 +191,4 @@ if (!Utility.checkIfAzurePythonSdkIsInstalled()) {
189191
tl.setResult(tl.TaskResult.Failed, tl.loc("AzureSDKNotFound"));
190192
}
191193

192-
azureclitask.runMain();
194+
azureclitask.runMain();

Tasks/AzureCLIV2/task.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"version": {
2121
"Major": 2,
2222
"Minor": 0,
23-
"Patch": 10
23+
"Patch": 12
2424
},
2525
"minimumAgentVersion": "2.0.0",
2626
"instanceNameFormat": "Azure CLI $(scriptPath)",
@@ -39,11 +39,11 @@
3939
"azureSubscription"
4040
],
4141
"type": "connectedService:AzureRM",
42-
"label": "Azure subscription",
42+
"label": "Azure Resource Manager connection",
4343
"required": true,
44-
"helpMarkDown": "Select an Azure resource manager subscription for the deployment",
44+
"helpMarkDown": "Select an Azure Resource Manager service connection for the deployment",
4545
"properties": {
46-
"EndpointFilterRule": "ScopeLevel != ManagementGroup"
46+
"EndpointFilterRule": ""
4747
}
4848
},
4949
{
@@ -198,4 +198,4 @@
198198
"GlobalCliConfigAgentVersionWarning": "For agent version < 2.115.0, only global Azure CLI configuration can be used",
199199
"UnacceptedScriptLocationValue": "%s is not a valid value for task input 'Script Location' (scriptLocation in YAML). Value can either be'inlineScript' or 'scriptPath'"
200200
}
201-
}
201+
}

Tasks/AzureCLIV2/task.loc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"version": {
2121
"Major": 2,
2222
"Minor": 0,
23-
"Patch": 10
23+
"Patch": 12
2424
},
2525
"minimumAgentVersion": "2.0.0",
2626
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
@@ -43,7 +43,7 @@
4343
"required": true,
4444
"helpMarkDown": "ms-resource:loc.input.help.connectedServiceNameARM",
4545
"properties": {
46-
"EndpointFilterRule": "ScopeLevel != ManagementGroup"
46+
"EndpointFilterRule": ""
4747
}
4848
},
4949
{

0 commit comments

Comments
 (0)