-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[SQL] Support setting of AAD administrator on Managed Instance #10446
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] Support setting of AAD administrator on Managed Instance #10446
Conversation
…Malesevic/azure-cli into setAADAdminOnMiCliCommands
|
@jaredmoo please review and let us know when it is ready to merge. |
| c.argument('managed_instance_name', | ||
| arg_type=managed_instance_param_type) | ||
|
|
||
| c.argument('login', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please define arg types (at top of file) that can be used for both sql server and MI arguments, instead of copying
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
|
||
| with self.argument_context('sql mi ad-admin create') as c: | ||
| # Create args that will be used to build up the ManagedInstanceAdministrator object | ||
| create_args_for_complex_type( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can put this in sql mi ad-admin section so that it applies to both create and update (to avoid repetition)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried to do this, but when executing get or delete command get the following error: ValueError: command authoring error: extra argument 'login' cannot be registered to a group-level scope 'sql mi ad-admin'. It must be registered to a specific command.
So, I need to keep both "sql mi ad-admin create" and "sql mi ad-admin update" sections.
| server_key_name=key_name | ||
| ) | ||
| server_key_type=server_key_type, | ||
| server_key_name=key_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build wasn't successful because of failed test test_sql_tdebyok (azure.cli.command_modules.sql.tests.latest.test_sql_commands.SqlTransparentDataEncryptionScenarioTest). You can find more on this link https://github.com/Azure/azure-cli/runs/214404678.
After I've fixed this, all checks have passed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Azure/azure-sdk-for-python@58857ae
@zikalino , can you clarify why this breaking change happened?
|
|
||
| profile = Profile() | ||
| sub = profile.get_subscription() | ||
| kwargs['tenant_id'] = sub['tenantId'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please extract function which gets tenant id so that the logic isn't duplicated between server and mi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/azure-cli/HISTORY.rst
Outdated
|
|
||
| **SQL** | ||
|
|
||
| * New Cmdlets for Management.Sql that supports setting AAD administrator on Managed instance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of "Management.Sql", please use the command names i.e. "sql mi ad-admin"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| """ | ||
| helps['sql mi ad-admin create'] = """ | ||
| type: command | ||
| short-summary: Create a new managed instance Active Directory administrator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| """ | ||
| helps['sql mi ad-admin update'] = """ | ||
| type: command | ||
| short-summary: Update an existing managed instance Active Directory administrator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
|
||
|
|
||
| def _get_tenant_id(): | ||
| from azure.cli.core._profile import Profile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add '''description''' to function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| return client.create_or_update( | ||
| resource_group_name=resource_group_name, | ||
| managed_instance_name=managed_instance_name, | ||
| administrator_name="ActiveDirectory", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define constant, e.g. ACTIVE_DIRECTORY = "ActiveDirectory" so that string isn't repeated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also unclear why this is needed compared to SQL server admin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skip this for now, because it will be removed after we change api specification and update the python client
| server_key_name=key_name | ||
| ) | ||
| server_key_type=server_key_type, | ||
| server_key_name=key_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Azure/azure-sdk-for-python@58857ae
@zikalino , can you clarify why this breaking change happened?
jaredmoo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Several comments but overall looks good
|
@jiasli please take a look and comment. |
|
please Rebase against the dev branch. Which should get Travis CI successfully run. |
|
@SanjaMalesevic Can you rebase against dev and fix the conflicts? We're going to build for the next release on Friday Shanghai time. |
|
This PR was merged and will be incorporated in our next release. |
This checklist is used to make sure that common guidelines for a pull request are followed.
The PR has modified HISTORY.rst describing any customer-facing, functional changes. Note that this does not include changes only to help content. (see Modifying change log).
I adhere to the Command Guidelines.