def __get_sql_steps(self, cmd, name, location, admin, password): from azure.cli.command_modules.sql._util import ( get_sql_management_client) from azure.cli.command_modules.sql.custom import ( server_create as sql_server_create, db_create as sql_database_create, firewall_rule_allow_all_azure_ips as sql_firewall_allow_azure, ComputeModelType) from azure.mgmt.sql.models import (Sku) sql_client = get_sql_management_client(cmd.cli_ctx) steps = [] server_parameters = { 'client': sql_client.servers, 'resource_group_name': name, 'server_name': name, 'location': location, 'version': '12.0', 'administrator_login': admin, 'administrator_login_password': password } steps.append( DatabaseCreationStep('server', sql_server_create, server_parameters)) sku = Sku(capacity=10, name='Standard', tier='Standard', family='Gen5') database_parameters = { 'cmd': cmd, 'client': sql_client.databases, 'database_name': name, 'server_name': name, 'resource_group_name': name, 'location': location, 'sku': sku, 'elastic_pool_id': None, 'compute_model': ComputeModelType('Serverless') } steps.append( DatabaseCreationStep('database', sql_database_create, database_parameters)) firewall_parameters = { 'client': sql_client.firewall_rules, 'server_name': name, 'resource_group_name': name } steps.append( DatabaseCreationStep('firewall', sql_firewall_allow_azure, firewall_parameters)) return steps
def __get_mysql_steps(self, cmd, name: str, location: str, admin: str, password: str): from azure.cli.command_modules.rdbms._client_factory import ( cf_mysql_servers, cf_mysql_db, cf_mysql_firewall_rules) from azure.mgmt.rdbms.mysql.models import ( ServerPropertiesForDefaultCreate, ServerForCreate, StorageProfile, Sku) mysql_server_client = cf_mysql_servers(cmd.cli_ctx, None) mysql_database_client = cf_mysql_db(cmd.cli_ctx, None) mysql_firewall_client = cf_mysql_firewall_rules(cmd.cli_ctx, None) admin = admin[:16] steps = [] server_params = { 'resource_group_name': name, 'server_name': name, 'parameters': ServerForCreate(sku=Sku(name='B_Gen5_1'), location=location, properties=ServerPropertiesForDefaultCreate( administrator_login=admin, administrator_login_password=password, version='5.7', ssl_enforcement='Enabled', storage_profile=StorageProfile( backup_retention_days=0, geo_redundant_backup='Disabled', storage_mb=5120))) } steps.append( DatabaseCreationStep('database server', mysql_server_client.create, server_params)) database_params = { 'resource_group_name': name, 'server_name': name, 'database_name': name } steps.append( DatabaseCreationStep('database', mysql_database_client.create_or_update, database_params)) firewall_params = { 'resource_group_name': name, 'server_name': name, 'firewall_rule_name': 'Azure', 'start_ip_address': '0.0.0.0', 'end_ip_address': '0.0.0.0' } steps.append( DatabaseCreationStep('database firewall', mysql_firewall_client.create_or_update, firewall_params)) return steps