-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Adding CRUD azure cli commands for Managed instance and Managed database resources #6428
Changes from 1 commit
1e8b0d2
00a3e49
ed33cdc
ef4e608
8a0bf79
bdb1c99
e38567a
5e6c067
2e27e38
7ea3a7c
5186243
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -426,83 +426,83 @@ | |
- name: Create a vnet rule by providing the vnet and subnet name. The subnet id is created by taking the resource group name and subscription id of the SQL server. | ||
text: az sql server vnet-rule create --subnet subnetName --vnet-name vnetName | ||
""" | ||
helps['sql managed-instance'] = """ | ||
helps['sql mi'] = """ | ||
type: group | ||
short-summary: Manage SQL managed instances. | ||
""" | ||
helps['sql managed-instance create'] = """ | ||
helps['sql mi create'] = """ | ||
type: command | ||
short-summary: Create a managed instance. | ||
examples: | ||
- name: Create a managed instance with specified parameters and with identity | ||
text: az sql managed-instance create -g mygroup -n myinstance -l mylocation -i -u myusername -p mypassword --license-type mylicensetype --subnet mysubnetid --capacity vcorecapacity --storage storagesize --edition editionname --family familyname | ||
text: az sql mi create -g mygroup -n myinstance -l mylocation -i -u myusername -p mypassword --license-type mylicensetype --subnet mysubnetid --capacity vcorecapacity --storage storagesize --edition editionname --family familyname | ||
""" | ||
helps['sql managed-instance list'] = """ | ||
helps['sql mi list'] = """ | ||
type: command | ||
short-summary: List available managed instances. | ||
examples: | ||
- name: List all managed instances in the current subscription. | ||
text: az sql managed-instance list | ||
text: az sql mi list | ||
- name: List all managed instances in a resource group. | ||
text: az sql managed-instance list -g mygroup | ||
text: az sql mi list -g mygroup | ||
""" | ||
helps['sql managed-instance show'] = """ | ||
helps['sql mi show'] = """ | ||
type: command | ||
short-summary: Get the details for a managed instance. | ||
examples: | ||
- name: Get the details for a managed instance | ||
text: az sql managed-instance show -g mygroup -n myinstance | ||
text: az sql mi show -g mygroup -n myinstance | ||
""" | ||
helps['sql managed-instance update'] = """ | ||
helps['sql mi update'] = """ | ||
type: command | ||
short-summary: Update a managed instance. | ||
examples: | ||
- name: Updates a managed-instance with specified parameters and with identity | ||
text: az sql managed-instance update -g mygroup -n myinstance -i -p mypassword --license-type mylicensetype --capacity vcorecapacity --storage storagesize | ||
- name: Updates a mi with specified parameters and with identity | ||
text: az sql mi update -g mygroup -n myinstance -i -p mypassword --license-type mylicensetype --capacity vcorecapacity --storage storagesize | ||
""" | ||
helps['sql managed-instance delete'] = """ | ||
helps['sql mi delete'] = """ | ||
type: command | ||
short-summary: Delete a managed instance. | ||
examples: | ||
- name: Delete a managed instance | ||
text: az sql managed-instance delete -g mygroup -n myinstance --yes | ||
text: az sql mi delete -g mygroup -n myinstance --yes | ||
""" | ||
helps['sql managed-db'] = """ | ||
helps['sql midb'] = """ | ||
type: group | ||
short-summary: Manage SQL managed databases. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you change this to |
||
""" | ||
helps['sql managed-db create'] = """ | ||
helps['sql midb create'] = """ | ||
type: command | ||
short-summary: Create a managed database. | ||
examples: | ||
- name: Create a managed database with specified collation | ||
text: az sql managed-db create -g mygroup --mi myinstance -n mymanageddb --collation Latin1_General_100_CS_AS_SC | ||
text: az sql midb create -g mygroup --mi myinstance -n mymanageddb --collation Latin1_General_100_CS_AS_SC | ||
""" | ||
helps['sql managed-db list'] = """ | ||
helps['sql midb list'] = """ | ||
type: command | ||
short-summary: List maanged databases on a managed instance. | ||
examples: | ||
- name: List managed databases on a managed instance | ||
text: az sql managed-db list -g mygroup --mi myinstance | ||
text: az sql midb list -g mygroup --mi myinstance | ||
""" | ||
helps['sql managed-db show'] = """ | ||
helps['sql midb show'] = """ | ||
type: command | ||
short-summary: Get the details for a managed database. | ||
examples: | ||
- name: Get the details for a managed database | ||
text: az sql managed-db show -g mygroup --mi myinstance -n mymanageddb | ||
text: az sql midb show -g mygroup --mi myinstance -n mymanageddb | ||
""" | ||
helps['sql managed-db restore'] = """ | ||
helps['sql midb restore'] = """ | ||
type: command | ||
short-summary: Restore a managed database. | ||
examples: | ||
- name: Restore a managed database using Point in time restore | ||
text: az sql managed-db restore -g mygroup --mi myinstance -n mymanageddb --target-db targetmidb --time "2018-05-20T05:34:22" | ||
text: az sql midb restore -g mygroup --mi myinstance -n mymanageddb --target-db targetmidb --time "2018-05-20T05:34:22" | ||
""" | ||
helps['sql managed-db delete'] = """ | ||
helps['sql midb delete'] = """ | ||
type: command | ||
short-summary: Delete a managed database. | ||
examples: | ||
- name: Delete a managed database | ||
text: az sql managed-db delete -g mygroup --mi myinstance -n mymanageddb --yes | ||
text: az sql midb delete -g mygroup --mi myinstance -n mymanageddb --yes | ||
""" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,7 +160,6 @@ def __repr__(self): | |
|
||
db_service_objective_examples = 'Basic, S0, P1, GP_Gen4_1, BC_Gen5_2.' | ||
dw_service_objective_examples = 'DW100, DW1000c' | ||
mi_service_objective_examples = 'GP_Gen4, GP_Gen5' | ||
|
||
|
||
############################################### | ||
|
@@ -1027,7 +1026,7 @@ def _configure_security_policy_storage_params(arg_ctx): | |
############################################### | ||
# sql managed instance # | ||
############################################### | ||
with self.argument_context('sql managed-instance') as c: | ||
with self.argument_context('sql mi') as c: | ||
c.argument('managed_instance_name', | ||
help='The managed instance name', | ||
options_list=['--name', '-n'], | ||
|
@@ -1046,7 +1045,7 @@ def _configure_security_policy_storage_params(arg_ctx): | |
c.argument('storage_size_in_gb', | ||
options_list=['--storage'], | ||
arg_type=storage_param_type, | ||
help='Determines how much storage size to associate with Managed instance. ' | ||
help='The storage size of the managed instance. ' | ||
'Storage size must be specified in increments of 32 GB') | ||
|
||
c.argument('license_type', | ||
|
@@ -1055,9 +1054,9 @@ def _configure_security_policy_storage_params(arg_ctx): | |
|
||
c.argument('vcores', | ||
options_list=['--capacity', '-c'], | ||
help='Determines how much VCore to associate with Managed instance.') | ||
help='The capacity of the managed instance in vcores.') | ||
|
||
with self.argument_context('sql managed-instance create') as c: | ||
with self.argument_context('sql mi create') as c: | ||
# Create args that will be used to build up the ManagedInstance object | ||
create_args_for_complex_type( | ||
c, 'parameters', ManagedInstance, [ | ||
|
@@ -1103,7 +1102,7 @@ def _configure_security_policy_storage_params(arg_ctx): | |
help='Generate and assign an Azure Active Directory Identity for this managed instance ' | ||
'for use with key management services like Azure KeyVault.') | ||
|
||
with self.argument_context('sql managed-instance update') as c: | ||
with self.argument_context('sql mi update') as c: | ||
# Create args that will be used to build up the ManagedInstance object | ||
create_args_for_complex_type( | ||
c, 'parameters', ManagedInstance, [ | ||
|
@@ -1121,7 +1120,7 @@ def _configure_security_policy_storage_params(arg_ctx): | |
############################################### | ||
# sql managed db # | ||
############################################### | ||
with self.argument_context('sql managed-db') as c: | ||
with self.argument_context('sql midb') as c: | ||
c.argument('managed_instance_name', | ||
arg_type=managed_instance_param_type, | ||
# Allow --ids command line argument. id_part=name is 1st name in uri | ||
|
@@ -1133,7 +1132,7 @@ def _configure_security_policy_storage_params(arg_ctx): | |
# Allow --ids command line argument. id_part=child_name_1 is 2nd name in uri | ||
id_part='child_name_1') | ||
|
||
with self.argument_context('sql managed-db create') as c: | ||
with self.argument_context('sql midb create') as c: | ||
create_args_for_complex_type( | ||
c, 'parameters', ManagedDatabase, [ | ||
'collation', | ||
|
@@ -1144,17 +1143,25 @@ def _configure_security_policy_storage_params(arg_ctx): | |
help='The collation of the Azure SQL Managed Database collation to use, ' | ||
'e.g.: SQL_Latin1_General_CP1_CI_AS or Latin1_General_100_CS_AS_SC') | ||
|
||
with self.argument_context('sql managed-db restore') as c: | ||
with self.argument_context('sql midb restore') as c: | ||
create_args_for_complex_type( | ||
c, 'parameters', ManagedDatabase, [ | ||
'target_managed_database_name', | ||
'target_managed_instance_name', | ||
'restore_point_in_time' | ||
]) | ||
|
||
c.argument('target_managed_database_name', | ||
options_list=['--target-db'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just remembered that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed to --dest-name and --dest-mi |
||
required=True, | ||
help='Name of the managed database that will be created as the restore destination.') | ||
|
||
c.argument('target_managed_instance_name', | ||
options_list=['--target-mi'], | ||
help='Name of the managed instance to restore managed database to. ' | ||
'This can be same managed instance, or another managed instance withing same resource group. ' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo Is it not possible to specify another resource group? We have this for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! You are right, we can specify different rg. Fixed. |
||
'When not specified it defaults to source managed instance.') | ||
|
||
restore_point_arg_group = 'Restore Point' | ||
|
||
c.argument('restore_point_in_time', | ||
|
@@ -1165,5 +1172,5 @@ def _configure_security_policy_storage_params(arg_ctx): | |
' new database. Must be greater than or equal to the source database\'s' | ||
' earliestRestoreDate value. Time should be in following format: "YYYY-MM-DDTHH:MM:SS"') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very nice! |
||
|
||
with self.argument_context('sql managed-db list') as c: | ||
with self.argument_context('sql midb list') as c: | ||
c.argument('managed_instance_name', id_part=None) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This supresses the --ids parameter from sql managed-db list command as per: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add comment explaining what this does and why? That will help the next person to read this :) |
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.
Let's have more real-looking values where possible. i.e.:
az sql mi create -g mygroup -n myinstance -l mylocation -i -u myusername -p mypassword --license-type LicenseIncluded --subnet /subscriptions/{SubID}/resourceGroups/{ResourceGroup}/providers/Microsoft.Network/virtualNetworks/{VNETName}/subnets/{SubnetName} --capacity 2 --storage 32GB --edition BusinessCritical --family Gen4
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.
Thanks for adding example btw :) Can you also add example with minimal parameters?