I need to create a Azure SQL Data Warehouse using python. I could not find any documentation for this. I was able to create the resource group and SQL server using python.
Create resource group:
def create_resource():
# Create Resource group
print('Create Resource Group')
print_item(client.resource_groups.create_or_update(group_name, resource_group_params))
Create sql server :
def create_sql_server():
# Create SQL Instances
print('Create SQL Instances')
sql_client.servers.create_or_update(
group_name,
server_name,
{
'location': region,
'version': '12.0', # Required for create
'administrator_login': 'ttt', # Required for create
'administrator_login_password': 'ttt' # Required for create
}
)
I was able to do this using a Rest API:
def create_dwh():
# Create sql data warehouse
print('Create sql data warehouse')
# this will return a azure api token
token=TokenMgt.get_token()
headers = {'Content-Type': 'application/json',
'Authorization': token}
# parameters
# subscription_id : azure subscription id
# group_name : azure resource group
# server_name : SQL server name
# dwh_name : data warehouse db name
api_url = dwh_end_point.format(subscription_id, group_name, server_name, dwh_name)
print(api_url)
data = {
"location": "westus",
"sku": {
"name": "DW100c"
}
}
print(data)
query_params = {'api-version': '2017-10-01-preview'}
response = requests.put(url = api_url, params = query_params, json = data, headers = headers)
response_data = response.json()
print(response_data)