Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear azure rm context in initialize azure #7778

Merged
merged 2 commits into from
Jul 23, 2018

Conversation

SumiranAgg
Copy link
Contributor

No description provided.

if (Get-Command -Name "Add-AzureRmAccount" -ErrorAction "SilentlyContinue") {
if (Get-Command -Name "Add-AzureRmAccount" -ErrorAction "SilentlyContinue") {
Write-Host "##[command]Clear-AzureRmContext -Scope Process"
$null = Clear-AzureRmContext -Scope Process
Copy link
Member

Choose a reason for hiding this comment

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

Do you know the PS version from which this command is supported?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the command is available from version 4.

Copy link

Choose a reason for hiding this comment

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

Can you please check if this cmdlet exists. I think that way it won't even break for customers on version less that 4 too.

Copy link

Choose a reason for hiding this comment

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

Can you please check if this cmdlet exists. I think that way it won't even break for customers on version less than 4 too.

Copy link

Choose a reason for hiding this comment

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

Should we move this cmdlet outside of the if condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AS per offline discussion made changes

Write-Host "##[command]Clear-AzureRmContext -Scope Process"
$null = Clear-AzureRmContext -Scope Process
Write-Host "##[command]Clear-AzureRmContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue"
$null = Clear-AzureRmContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue
Copy link
Member

Choose a reason for hiding this comment

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

Wasn't there recommendation to actually to Set-AzureRMContext?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The recommendation was to Select-AzureRmContext, but that will not resolve all issues. We are still under discussion with Azure PS team. In the meanwhile, this is the fix we have recognized.

@SumiranAgg SumiranAgg merged commit 8cd3c6d into master Jul 23, 2018
@SumiranAgg SumiranAgg deleted the users/suaggar/fixContextPersists branch July 23, 2018 06:01
SumiranAgg added a commit that referenced this pull request Jul 25, 2018
* Clear azure rm context in initialize azure

* resolve PR commets
SumiranAgg added a commit that referenced this pull request Jul 25, 2018
* Clear azure rm context in initialize azure

* resolve PR commets
SumiranAgg added a commit that referenced this pull request Aug 22, 2018
* Clear azure rm context in initialize azure (#7778)

* Clear azure rm context in initialize azure

* resolve PR commets

* clear context before azure stack

* merge fix

* AFC patch update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants