Skip to content

PR to include support for Sovereign cloud in azlogin action - #85

Merged
Zainudeen V K (zainuvk) merged 12 commits into
azuresovereigncloudfrom
releases/azcloud-v1
Dec 10, 2020
Merged

PR to include support for Sovereign cloud in azlogin action#85
Zainudeen V K (zainuvk) merged 12 commits into
azuresovereigncloudfrom
releases/azcloud-v1

Conversation

@zainuvk

Copy link
Copy Markdown

The PR is to include support for Azure Gov Cloud. The details are listed in ADR doc:

https://github.com/github/Microsoft-Attach/blob/users/zainudv/actionsazuregovcloud/adrs/azure-integration/GitHubAction_AzureGovCloudIntegration.md

We took the #4 approach mentioned in ADR to align with Azure stack

Comment thread src/main.ts Outdated
@aksm-ms

aksm-ms commented Dec 4, 2020

Copy link
Copy Markdown
Contributor

Zainudeen V K (@zainuvk) is azure powershell login handled for sovereign cloud support? Currently in azure powershell login in sovereign cloud branch, environment is set only for azurestack

if (args.environment.toLowerCase() == "azurestack") {
                command += `Add-AzEnvironment -Name ${args.environment} -ARMEndpoint ${args.resourceManagerEndpointUrl} | out-null;`;
 }

Reference - https://github.com/Azure/login/blob/azuresovereigncloud/src/PowerShell/Utilities/ScriptBuilder.ts#L12

@zainuvk Zainudeen V K (zainuvk) left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aksm-ms From the document available

https://docs.microsoft.com/en-us/azure/azure-government/documentation-government-get-started-connect-with-ps#specifying-azure-government-as-the-environment-to-connect-to

This is what that is documented:

When you start PowerShell, you have to tell Azure PowerShell to connect to Azure Government by specifying an environment parameter. The parameter ensures that PowerShell is connecting to the correct endpoints. The collection of endpoints is determined when you connect log in to your account. Different APIs require different versions of the environment switch:

Connection type Command
Azure commands Connect-AzAccount -EnvironmentName AzureUSGovernment

The code in getAzPSLoginScript would set Environment variable passed in command and then execute the same.

let command = Clear-AzContext -Scope Process; Clear-AzContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue;;
if (scheme === Constants.ServicePrincipal) {
if (args.environment.toLowerCase() == "azurestack") {
command += Add-AzEnvironment -Name ${args.environment} -ARMEndpoint ${args.resourceManagerEndpointUrl} | out-null;;
}
command += Connect-AzAccount -ServicePrincipal -Tenant '${tenantId}' -Credential \ (New-Object System.Management.Automation.PSCredential('${args.servicePrincipalId}',(ConvertTo-SecureString '${args.servicePrincipalKey.replace("'", "''")}' -AsPlainText -Force))) \ -Environment '${args.environment}' | out-null;;
if (args.scopeLevel === Constants.Subscription) {
command += Set-AzContext -SubscriptionId '${args.subscriptionId}' -TenantId '${tenantId}' | out-null;;
}
}

This workflow infact test both az cli and az powershell for various combination of input to azlogin https://github.com/Azure/azure-actions-integration-tests/blob/master/.github/workflows/azlogin_test.yml

Please feel free to let me know if you see any issues here or if my understanding is incorrect.

Comment thread src/main.ts Outdated
Comment thread src/PowerShell/Enums.ts Outdated
@@ -0,0 +1,7 @@
export enum AzureCloudName {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PowerShell folder has code changes related to Azure Powershell login. Sovereign cloud changes should be made in both az cli login and powershell login, hence please move it outside.

Comment thread src/main.ts Outdated
Comment thread src/main.ts Outdated
@asranja

Copy link
Copy Markdown
Contributor

Please update the PR title.

Comment thread src/main.ts Outdated
Comment thread src/main.ts Outdated
Comment thread src/main.ts Outdated
}

// Attempting Az cli login
if (environment.toLowerCase() == "azurestack") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this entire if block in a separate method like RegisterAzureStackEnvironment()

@zainuvk Zainudeen V K (zainuvk) Dec 7, 2020

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ashish Ranjan (@asranja) since this is an existing code of Azure stack I am not very comfortable on touching stack code.And for that reason we branched out separately for Soverign cloud. There is a separate branch for stack changes and this can be done there.

Comment thread src/main.ts Outdated
}
let suffixKeyvault = ".vault" + baseUri.substring(baseUri.indexOf('.')); // keyvault suffix starts with .
let suffixStorage = baseUri.substring(baseUri.indexOf('.')+1); // storage suffix starts without .
let profileVersion = "2019-03-01-hybrid";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this a global constant like

const AZURE_STACK_PROFILE_VERSION = "2019-03-01-hybrid"

Comment thread src/main.ts Outdated
Comment thread src/main.ts Outdated
Comment thread src/main.ts Outdated
Comment thread src/main.ts Outdated
Comment thread src/main.ts Outdated
Comment thread src/main.ts Outdated
Comment thread src/main.ts Outdated
Comment thread src/main.ts Outdated
@zainuvk Zainudeen V K (zainuvk) changed the title Releases/azcloud v1 PR To include support for Sovereign cloud in azlogin action Dec 7, 2020
@zainuvk Zainudeen V K (zainuvk) changed the title PR To include support for Sovereign cloud in azlogin action PR to include support for Sovereign cloud in azlogin action Dec 7, 2020
Comment thread src/main.ts Outdated
Comment thread src/PowerShell/Constants.ts Outdated
@zainuvk
Zainudeen V K (zainuvk) merged commit 4440d80 into azuresovereigncloud Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants