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

[SQL] Fix null ref when not logged into Azure account for all sql cmdlets #8411

Merged
merged 3 commits into from
Jan 29, 2019
Merged

[SQL] Fix null ref when not logged into Azure account for all sql cmdlets #8411

merged 3 commits into from
Jan 29, 2019

Conversation

adeal
Copy link
Contributor

@adeal adeal commented Jan 26, 2019

Description

Current behavior of SQL cmdlets inheriting from AzureSqlCmdletBase results in the user getting a nullref exception when using a command prior to logging into their AzAccount. This is caused by the existing code unconditionally accessing DefaultProfile.DefaultContext.Subscription, which only gets set upon login.

This change fixes this behavior by:

  1. Change the signature of AzureSqlCmdletBase.InitModelAdapter() to no longer have a IAzureSubscription parameter
  2. Conditionally access IAzureContext.Subscription

Existing behavior:
before

New behavior:
after

Checklist

Copy link
Contributor

@jaredmoo jaredmoo left a comment

Choose a reason for hiding this comment

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

Thank you!

@vladimir-shcherbakov
Copy link
Contributor

@cormacpayne cormacpayne merged commit ddf937f into Azure:master Jan 29, 2019
@adeal adeal deleted the SqlFixNullRef branch January 29, 2019 17:42
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.

5 participants