ASDE updates (#12134)

* add storage account cleanup and other misc stuff

* force load

* cell -> code cell
This commit is contained in:
Alan Ren
2020-09-03 22:12:10 -07:00
committed by GitHub
parent 4cc3a3f788
commit 1e49e47a37
5 changed files with 75 additions and 1 deletions

View File

@@ -279,6 +279,7 @@
{
"cell_type": "code",
"source": [
"storage_account_created = False\n",
"if dacpac_path == \"\":\n",
" print(f'Dacpac zip file not provided')\n",
" blob_sas = ''\n",
@@ -287,6 +288,7 @@
" storage_accounts = run_command(f'az storage account list --resource-group {azure_resource_group} --subscription {azure_subscription_id}', returnObject=True)\n",
" storage_accounts = [storage_account for storage_account in storage_accounts if storage_account['name'] == azure_storage_account]\n",
" if len(storage_accounts) == 0:\n",
" storage_account_created = True\n",
" run_command(f'az storage account create -n {azure_storage_account} -g {azure_resource_group} -l {azure_location} --sku Standard_LRS --kind Storage')\n",
" else:\n",
" print(f'storage account \\\"{azure_storage_account}\\\" already exists.')\n",
@@ -517,6 +519,23 @@
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"source": [
"if storage_account_created:\r\n",
" delete_storage_account_command = \"run_command(f'az storage account delete -n {azure_storage_account} -g {azure_resource_group} --yes')\"\r\n",
" display(HTML('<span style=\"color:red\"><font size=\"2\">NOTE: A storage account was created to host the dacpac file, you can delete it after the database is created and populated successfully. To delete the storage account, copy the following code to a new code cell and run the cell.</font></span>'))\r\n",
" display(HTML('<span><font size=\"2\">'+delete_storage_account_command+'</font></span>'))"
],
"metadata": {
"azdata_cell_guid": "8b74ac43-a871-4d28-832d-e6da586f6d3a",
"tags": [
"hide_input"
]
},
"outputs": [],
"execution_count": null
}
]
}

View File

@@ -256,6 +256,7 @@
{
"cell_type": "code",
"source": [
"storage_account_created = False\n",
"if dacpac_path == \"\":\n",
" print(f'Dacpac zip file not provided')\n",
" blob_sas = ''\n",
@@ -264,6 +265,7 @@
" storage_accounts = run_command(f'az storage account list --resource-group {azure_resource_group} --subscription {azure_subscription_id}', returnObject=True)\n",
" storage_accounts = [storage_account for storage_account in storage_accounts if storage_account['name'] == azure_storage_account]\n",
" if len(storage_accounts) == 0:\n",
" storage_account_created = True\n",
" run_command(f'az storage account create -n {azure_storage_account} -g {azure_resource_group} --sku Standard_LRS --kind Storage')\n",
" else:\n",
" print(f'storage account \\\"{azure_storage_account}\\\" already exists.')\n",
@@ -322,6 +324,24 @@
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"source": [
"from IPython.display import *\r\n",
"if storage_account_created:\r\n",
" delete_storage_account_command = \"run_command(f'az storage account delete -n {azure_storage_account} -g {azure_resource_group} --yes')\"\r\n",
" display(HTML('<span style=\"color:red\"><font size=\"2\">NOTE: A storage account was created to host the dacpac file, you can delete it after the database is created and populated successfully. To delete the storage account, copy the following code to a new code cell and run the cell.</font></span>'))\r\n",
" display(HTML('<span><font size=\"2\">'+delete_storage_account_command+'</font></span>'))"
],
"metadata": {
"azdata_cell_guid": "13d698eb-4c1c-42e4-be28-efb9bf8b8c37",
"tags": [
"hide_input"
]
},
"outputs": [],
"execution_count": null
}
]
}

View File

@@ -264,6 +264,7 @@
{
"cell_type": "code",
"source": [
"storage_account_created = False\n",
"if dacpac_path == \"\":\n",
" print(f'Dacpac zip file not provided')\n",
" blob_sas = ''\n",
@@ -272,6 +273,7 @@
" storage_accounts = run_command(f'az storage account list --resource-group {azure_resource_group} --subscription {azure_subscription_id}', returnObject=True)\n",
" storage_accounts = [storage_account for storage_account in storage_accounts if storage_account['name'] == azure_storage_account]\n",
" if len(storage_accounts) == 0:\n",
" storage_account_created = True\n",
" run_command(f'az storage account create -n {azure_storage_account} -g {azure_resource_group} --sku Standard_LRS --kind Storage')\n",
" else:\n",
" print(f'storage account \\\"{azure_storage_account}\\\" already exists.')\n",
@@ -360,6 +362,23 @@
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"source": [
"if storage_account_created:\r\n",
" delete_storage_account_command = \"run_command(f'az storage account delete -n {azure_storage_account} -g {azure_resource_group} --yes')\"\r\n",
" display(HTML('<span style=\"color:red\"><font size=\"2\">NOTE: A storage account was created to host the dacpac file, you can delete it after the database is created and populated successfully. To delete the storage account, copy the following code to a new code cell and run the cell.</font></span>'))\r\n",
" display(HTML('<span><font size=\"2\">'+delete_storage_account_command+'</font></span>'))"
],
"metadata": {
"azdata_cell_guid": "e9d4188e-11c8-4aa5-8320-c3d0f6d023b2",
"tags": [
"hide_input"
]
},
"outputs": [],
"execution_count": null
}
]
}