deploy-MLmodels-on-iotedge/object-detection-azureml/06_TearDown.ipynb

122 строки
2.6 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Tear it all down\n",
"Once you are done with your task you can use the following commands to clean up resources."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from dotenv import set_key, get_key, find_dotenv"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"env_path = find_dotenv(raise_error_if_not_found=True)\n",
"resource_group = get_key(env_path, 'resource_group')\n",
"iot_hub_name = get_key(env_path, 'iot_hub_name')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!sudo systemctl stop iotedge"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!sudo apt-get remove -y iotedge"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Delete the IoT hub. This step may take a few minutes."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Delete IoT hub\n",
"cmd_results = !az iot hub show -n $iot_hub_name -g $resource_group\n",
"if 'Not Found' not in cmd_results[0]:\n",
" !az iot hub delete --name $iot_hub_name --resource-group $resource_group"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Finally, you should delete the resource group. This also deletes the IoT hub and can be used instead of the above command if the resource group is only used for this purpose."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"cmd_results = !az group show -n $resource_group -o tsv\n",
"if \"not be found\" not in cmd_results[0]:\n",
" !az group delete --name $resource_group -y"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!docker stop $(docker ps -qa)\n",
"!docker rm $(docker ps -qa)"
]
}
],
"metadata": {
"jupytext": {
"formats": "ipynb"
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
}