Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save javieraespinosa/8d9e93cff61c675d74bd862975a84d5e to your computer and use it in GitHub Desktop.
Save javieraespinosa/8d9e93cff61c675d74bd862975a84d5e to your computer and use it in GitHub Desktop.
Create a Python app using Azure App Service.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Create a Python app using Azure App Service.ipynb",
"provenance": [],
"authorship_tag": "ABX9TyPNxS9tECpMT2NhLyhKBIDZ",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/javieraespinosa/8d9e93cff61c675d74bd862975a84d5e/create-a-python-app-using-azure-app-service.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"source": [
"# Create a Python app using Azure App Service\n",
"\n",
"See [original instructions](https://docs.microsoft.com/en-us/azure/app-service/quickstart-python?tabs=bash&pivots=python-framework-flask) for more information\n",
"\n"
],
"metadata": {
"id": "TENHX_hPG5ks"
}
},
{
"cell_type": "markdown",
"source": [
"# Environment Setup"
],
"metadata": {
"id": "wB1jHNX1H5bT"
}
},
{
"cell_type": "markdown",
"source": [
"Install the Azure CLI"
],
"metadata": {
"id": "vF31S2HlbLCj"
}
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"id": "9bsZm5jAajlD",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "10ba5107-a13d-42a8-c622-2e793add26b1"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"\r0% [Working]\r \rIgn:1 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu2004/x86_64 InRelease\n",
"\r0% [Connecting to archive.ubuntu.com (91.189.91.38)] [Connecting to security.ub\r \rHit:2 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 InRelease\n",
"\r0% [Waiting for headers] [Connecting to security.ubuntu.com] [Waiting for heade\r \rGet:3 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ InRelease [3,622 B]\n",
"\r0% [Waiting for headers] [Connecting to security.ubuntu.com] [Connecting to ppa\r \rHit:4 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu2004/x86_64 Release\n",
"Hit:5 http://archive.ubuntu.com/ubuntu focal InRelease\n",
"Get:6 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]\n",
"Hit:7 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu focal InRelease\n",
"Get:8 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]\n",
"Get:9 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]\n",
"Hit:10 http://ppa.launchpad.net/cran/libgit2/ubuntu focal InRelease\n",
"Hit:12 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal InRelease\n",
"Hit:13 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu focal InRelease\n",
"Get:14 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [1,299 kB]\n",
"Hit:15 http://ppa.launchpad.net/ubuntugis/ppa/ubuntu focal InRelease\n",
"Get:16 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [2,972 kB]\n",
"Get:17 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [2,069 kB]\n",
"Get:18 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [1,000 kB]\n",
"Fetched 7,679 kB in 3s (2,449 kB/s)\n",
"Reading package lists... Done\n",
"Reading package lists... Done\n",
"Building dependency tree \n",
"Reading state information... Done\n",
"lsb-release is already the newest version (11.1.0ubuntu2).\n",
"lsb-release set to manually installed.\n",
"curl is already the newest version (7.68.0-1ubuntu2.15).\n",
"gnupg is already the newest version (2.2.19-3ubuntu2.2).\n",
"gnupg set to manually installed.\n",
"The following NEW packages will be installed:\n",
" apt-transport-https\n",
"0 upgraded, 1 newly installed, 0 to remove and 19 not upgraded.\n",
"Need to get 1,704 B of archives.\n",
"After this operation, 162 kB of additional disk space will be used.\n",
"Get:1 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 apt-transport-https all 2.0.9 [1,704 B]\n",
"Fetched 1,704 B in 0s (11.1 kB/s)\n",
"Selecting previously unselected package apt-transport-https.\n",
"(Reading database ... 128208 files and directories currently installed.)\n",
"Preparing to unpack .../apt-transport-https_2.0.9_all.deb ...\n",
"Unpacking apt-transport-https (2.0.9) ...\n",
"Setting up apt-transport-https (2.0.9) ...\n",
"Hit:1 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ InRelease\n",
"Ign:2 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu2004/x86_64 InRelease\n",
"Hit:3 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 InRelease\n",
"Hit:4 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu2004/x86_64 Release\n",
"Get:5 https://packages.microsoft.com/repos/azure-cli focal InRelease [10.4 kB]\n",
"Hit:6 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu focal InRelease\n",
"Hit:7 http://security.ubuntu.com/ubuntu focal-security InRelease\n",
"Hit:8 http://archive.ubuntu.com/ubuntu focal InRelease\n",
"Hit:10 http://archive.ubuntu.com/ubuntu focal-updates InRelease\n",
"Get:11 https://packages.microsoft.com/repos/azure-cli focal/main amd64 Packages [10.7 kB]\n",
"Hit:12 http://archive.ubuntu.com/ubuntu focal-backports InRelease\n",
"Hit:13 http://ppa.launchpad.net/cran/libgit2/ubuntu focal InRelease\n",
"Hit:14 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal InRelease\n",
"Hit:15 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu focal InRelease\n",
"Hit:16 http://ppa.launchpad.net/ubuntugis/ppa/ubuntu focal InRelease\n",
"Fetched 21.1 kB in 2s (13.1 kB/s)\n",
"Reading package lists... Done\n",
"Reading package lists... Done\n",
"Building dependency tree \n",
"Reading state information... Done\n",
"The following NEW packages will be installed:\n",
" azure-cli\n",
"0 upgraded, 1 newly installed, 0 to remove and 19 not upgraded.\n",
"Need to get 84.7 MB of archives.\n",
"After this operation, 1,250 MB of additional disk space will be used.\n",
"Get:1 https://packages.microsoft.com/repos/azure-cli focal/main amd64 azure-cli all 2.45.0-1~focal [84.7 MB]\n",
"Fetched 84.7 MB in 1s (69.1 MB/s)\n",
"Selecting previously unselected package azure-cli.\n",
"(Reading database ... 128212 files and directories currently installed.)\n",
"Preparing to unpack .../azure-cli_2.45.0-1~focal_all.deb ...\n",
"Unpacking azure-cli (2.45.0-1~focal) ...\n",
"Setting up azure-cli (2.45.0-1~focal) ...\n"
]
}
],
"source": [
"!curl -sL https://aka.ms/InstallAzureCLIDeb | bash"
]
},
{
"cell_type": "code",
"source": [
"!az --version"
],
"metadata": {
"id": "xtiAcEZha7-E",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "1455d20a-d92b-4fff-ddee-baa559a9a38f"
},
"execution_count": 2,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"azure-cli 2.45.0\n",
"\n",
"core 2.45.0\n",
"telemetry 1.0.8\n",
"\n",
"Dependencies:\n",
"msal 1.20.0\n",
"azure-mgmt-resource 21.1.0b1\n",
"\n",
"Python location '/opt/az/bin/python3'\n",
"Extensions directory '/root/.azure/cliextensions'\n",
"\n",
"Python (Linux) 3.10.8 (main, Feb 3 2023, 09:43:57) [GCC 9.4.0]\n",
"\n",
"Legal docs and information: aka.ms/AzureCliLegal\n",
"\n",
"\n",
"Your CLI is up-to-date.\n"
]
}
]
},
{
"cell_type": "markdown",
"source": [
"Configure Azure CLI"
],
"metadata": {
"id": "u2QFOtMPISjk"
}
},
{
"cell_type": "code",
"source": [
"# Once signed in, you can run Azure commands with the Azure CLI to work with resources in your subscription.\n",
"!az login"
],
"metadata": {
"id": "BOcDObrObgco",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "a91d5383-c7e3-48b7-861a-a483c0dda656"
},
"execution_count": 3,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"\u001b[93mTo sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code F6LT9DWTS to authenticate.\u001b[0m\n",
"[\n",
" {\n",
" \"cloudName\": \"AzureCloud\",\n",
" \"homeTenantId\": \"85a4f81d-3e02-434a-a501-51cf776d196e\",\n",
" \"id\": \"268e84a3-69f6-4c3a-b578-ceb8e312ce8a\",\n",
" \"isDefault\": true,\n",
" \"managedByTenants\": [],\n",
" \"name\": \"Azure for Students\",\n",
" \"state\": \"Enabled\",\n",
" \"tenantId\": \"85a4f81d-3e02-434a-a501-51cf776d196e\",\n",
" \"user\": {\n",
" \"name\": \"genoveva.vargas@cpe.fr\",\n",
" \"type\": \"user\"\n",
" }\n",
" }\n",
"]\n"
]
}
]
},
{
"cell_type": "markdown",
"source": [
"Install ngrok"
],
"metadata": {
"id": "8lEK4J3tNyxK"
}
},
{
"cell_type": "code",
"source": [
"!curl -O https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip\n",
"!unzip ngrok-stable-linux-amd64.zip"
],
"metadata": {
"id": "inInkNtgNxwU",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "b1171498-60d9-4ad4-b845-54f8b9861e71"
},
"execution_count": 4,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
" % Total % Received % Xferd Average Speed Time Time Time Current\n",
" Dload Upload Total Spent Left Speed\n",
"100 13.2M 100 13.2M 0 0 12.4M 0 0:00:01 0:00:01 --:--:-- 12.4M\n",
"Archive: ngrok-stable-linux-amd64.zip\n",
" inflating: ngrok \n"
]
}
]
},
{
"cell_type": "markdown",
"source": [
"Config ngrok with your own authtoken (see https://ngrok.com)"
],
"metadata": {
"id": "zJV_khjVPfcR"
}
},
{
"cell_type": "code",
"source": [
"NGROK_AUTHTOKEN = '2MAa1Nl8O68LRR8yh7qR3skzpAC_4yUaRiwFd6Q5q7nHbj6SP'"
],
"metadata": {
"id": "TeBlNkPqQ8oV"
},
"execution_count": 5,
"outputs": []
},
{
"cell_type": "code",
"source": [
"!./ngrok authtoken $NGROK_AUTHTOKEN"
],
"metadata": {
"id": "ALCUazqZOgJP",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "b3217c08-3615-4a5c-9c29-b65603fced7d"
},
"execution_count": 6,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Authtoken saved to configuration file: /root/.ngrok2/ngrok.yml\n"
]
}
]
},
{
"cell_type": "markdown",
"source": [
"# Clone the Sample"
],
"metadata": {
"id": "nfMRsROcIaxz"
}
},
{
"cell_type": "markdown",
"source": [
"Clone the sample repository (https://github.com/Azure-Samples/python-docs-hello-world)"
],
"metadata": {
"id": "6rTjbqjDSmDn"
}
},
{
"cell_type": "code",
"source": [
"#!git clone https://github.com/Azure-Samples/python-docs-hello-world\n",
"!git clone https://github.com/Azure-Samples/msdocs-python-flask-webapp-quickstart"
],
"metadata": {
"id": "JzVRBPTlbnzZ",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "2ce557d8-1843-4077-a190-d82ebd04decf"
},
"execution_count": 12,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Cloning into 'msdocs-python-flask-webapp-quickstart'...\n",
"remote: Enumerating objects: 108, done.\u001b[K\n",
"remote: Total 108 (delta 0), reused 0 (delta 0), pack-reused 108\u001b[K\n",
"Receiving objects: 100% (108/108), 781.06 KiB | 2.20 MiB/s, done.\n",
"Resolving deltas: 100% (49/49), done.\n"
]
}
]
},
{
"cell_type": "markdown",
"source": [
"Install python dependencies"
],
"metadata": {
"id": "Am4wq3OvTbTF"
}
},
{
"cell_type": "code",
"source": [
"# %cd python-docs-hello-world\n",
"%cd msdocs-python-flask-webapp-quickstart"
],
"metadata": {
"id": "KQqe8ttqb9-9",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "62e69518-c3cd-4ebc-ab69-3e7527d4bf2a"
},
"execution_count": 2,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"/content/msdocs-python-flask-webapp-quickstart\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!pip install -r requirements.txt"
],
"metadata": {
"id": "PNQSqWIscM-e",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "ab981be1-5c3c-4782-ad1d-2156f10bdf08"
},
"execution_count": 3,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
"Requirement already satisfied: Flask==2.0.2 in /usr/local/lib/python3.8/dist-packages (from -r requirements.txt (line 1)) (2.0.2)\n",
"Requirement already satisfied: Jinja2>=3.0 in /usr/local/lib/python3.8/dist-packages (from Flask==2.0.2->-r requirements.txt (line 1)) (3.1.2)\n",
"Requirement already satisfied: Werkzeug>=2.0 in /usr/local/lib/python3.8/dist-packages (from Flask==2.0.2->-r requirements.txt (line 1)) (2.2.3)\n",
"Requirement already satisfied: itsdangerous>=2.0 in /usr/local/lib/python3.8/dist-packages (from Flask==2.0.2->-r requirements.txt (line 1)) (2.1.2)\n",
"Requirement already satisfied: click>=7.1.2 in /usr/local/lib/python3.8/dist-packages (from Flask==2.0.2->-r requirements.txt (line 1)) (8.1.3)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.8/dist-packages (from Jinja2>=3.0->Flask==2.0.2->-r requirements.txt (line 1)) (2.1.2)\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"# This helps to run the sample in colab\n",
"!pip install flask-ngrok"
],
"metadata": {
"id": "1IMvDexXcuFH",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "05686645-1848-43b4-d70b-842f26620be5"
},
"execution_count": 10,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
"Collecting flask-ngrok\n",
" Downloading flask_ngrok-0.0.25-py3-none-any.whl (3.1 kB)\n",
"Requirement already satisfied: Flask>=0.8 in /usr/local/lib/python3.8/dist-packages (from flask-ngrok) (2.1.1)\n",
"Requirement already satisfied: requests in /usr/local/lib/python3.8/dist-packages (from flask-ngrok) (2.25.1)\n",
"Requirement already satisfied: importlib-metadata>=3.6.0 in /usr/local/lib/python3.8/dist-packages (from Flask>=0.8->flask-ngrok) (6.0.0)\n",
"Requirement already satisfied: itsdangerous>=2.0 in /usr/local/lib/python3.8/dist-packages (from Flask>=0.8->flask-ngrok) (2.1.2)\n",
"Requirement already satisfied: Jinja2>=3.0 in /usr/local/lib/python3.8/dist-packages (from Flask>=0.8->flask-ngrok) (3.1.2)\n",
"Requirement already satisfied: click>=8.0 in /usr/local/lib/python3.8/dist-packages (from Flask>=0.8->flask-ngrok) (8.1.3)\n",
"Requirement already satisfied: Werkzeug>=2.0 in /usr/local/lib/python3.8/dist-packages (from Flask>=0.8->flask-ngrok) (2.2.3)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.8/dist-packages (from requests->flask-ngrok) (2022.12.7)\n",
"Requirement already satisfied: chardet<5,>=3.0.2 in /usr/local/lib/python3.8/dist-packages (from requests->flask-ngrok) (4.0.0)\n",
"Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.8/dist-packages (from requests->flask-ngrok) (2.10)\n",
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.8/dist-packages (from requests->flask-ngrok) (1.24.3)\n",
"Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.8/dist-packages (from importlib-metadata>=3.6.0->Flask>=0.8->flask-ngrok) (3.14.0)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.8/dist-packages (from Jinja2>=3.0->Flask>=0.8->flask-ngrok) (2.1.2)\n",
"Installing collected packages: flask-ngrok\n",
"Successfully installed flask-ngrok-0.0.25\n"
]
}
]
},
{
"cell_type": "markdown",
"source": [
"# Run the Sample"
],
"metadata": {
"id": "GY_o9286Tl-V"
}
},
{
"cell_type": "markdown",
"source": [
"Sample file (`app.py`) content\n",
"\n",
"```python\n",
"from datetime import datetime\n",
"from flask import Flask, render_template, request, redirect, url_for, send_from_directory\n",
"app = Flask(__name__)\n",
"\n",
"@app.route('/')\n",
"def index():\n",
" print('Request for index page received')\n",
" return render_template('index.html')\n",
"\n",
"@app.route('/favicon.ico')\n",
"def favicon():\n",
" return send_from_directory(os.path.join(app.root_path, 'static'),\n",
" 'favicon.ico', mimetype='image/vnd.microsoft.icon')\n",
"\n",
"@app.route('/hello', methods=['POST'])\n",
"def hello():\n",
" name = request.form.get('name')\n",
"\n",
" if name:\n",
" print('Request for hello page received with name=%s' % name)\n",
" return render_template('hello.html', name = name)\n",
" else:\n",
" print('Request for hello page received with no name or blank name -- redirecting')\n",
" return redirect(url_for('index'))\n",
"\n",
"if __name__ == '__main__':\n",
" app.run()\n",
"```"
],
"metadata": {
"id": "FRy62QlraUJk"
}
},
{
"cell_type": "markdown",
"source": [
"Load and execute sample in colab. \n",
"\n",
"> Follow the ngrok URL to see the output (e.g., http://7023-35-227-55-73.ngrok.io)"
],
"metadata": {
"id": "ERBxaV7WUMqP"
}
},
{
"cell_type": "code",
"source": [
"# Load sample & remove last 2 lines for running the app with ngrok\n",
"with open('app.py') as sample:\n",
" code = sample.read().split(\"\\n\")\n",
" new_code = \"\\n\".join(code[:-2])\n",
" exec( new_code )\n",
"\n",
"# Config sample for running in colab\n",
"from flask_ngrok import run_with_ngrok\n",
"run_with_ngrok(app)\n",
"app.run() "
],
"metadata": {
"id": "e0npVe5EOM-Z",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 283
},
"outputId": "ab2658c4-7bca-4747-b77f-f4327a7b33e1"
},
"execution_count": 11,
"outputs": [
{
"output_type": "error",
"ename": "SyntaxError",
"evalue": "ignored",
"traceback": [
"Traceback \u001b[0;36m(most recent call last)\u001b[0m:\n",
" File \u001b[1;32m\"/usr/local/lib/python3.8/dist-packages/IPython/core/interactiveshell.py\"\u001b[0m, line \u001b[1;32m3326\u001b[0m, in \u001b[1;35mrun_code\u001b[0m\n exec(code_obj, self.user_global_ns, self.user_ns)\n",
"\u001b[0;36m File \u001b[0;32m\"<ipython-input-11-8b99a9abe31e>\"\u001b[0;36m, line \u001b[0;32m5\u001b[0;36m, in \u001b[0;35m<module>\u001b[0;36m\u001b[0m\n\u001b[0;31m exec( new_code )\u001b[0m\n",
"\u001b[0;36m File \u001b[0;32m\"<string>\"\u001b[0;36m, line \u001b[0;32m27\u001b[0m\n\u001b[0;31m if __name__ == '__main__':\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m unexpected EOF while parsing\n"
]
}
]
},
{
"cell_type": "markdown",
"source": [
"🤚 **Stop the previous cell before continuing**\n",
"\n"
],
"metadata": {
"id": "j3sHtxjMf1oW"
}
},
{
"cell_type": "markdown",
"source": [
"# Deploy the sample"
],
"metadata": {
"id": "SFW9V5lqWeR2"
}
},
{
"cell_type": "markdown",
"source": [
"Define a unique `APP_NAME`. This will be part of your app URL (e.g. `http://APP_NAME.azurewebsites.net`)\n"
],
"metadata": {
"id": "AFJT3BkfXU3V"
}
},
{
"cell_type": "code",
"source": [
"APP_NAME = 'sample-python-azure-app-service-cpe'"
],
"metadata": {
"id": "_gr7LLMcW_TA"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"Deploy the sample"
],
"metadata": {
"id": "8Wzm7G_YYqhe"
}
},
{
"cell_type": "code",
"source": [
"!az webapp up --sku F1 --name $APP_NAME"
],
"metadata": {
"id": "6MXauaHUkAvi"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"Test the app\n",
"\n",
"> The first connection takes some time because of the resources allocation"
],
"metadata": {
"id": "HmMwVx3yZLuc"
}
},
{
"cell_type": "code",
"source": [
"print('http://' + APP_NAME + '.azurewebsites.net')"
],
"metadata": {
"id": "tx3OjTTGZSsK"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"Modify the `app.py` file (double click in the file icon and save). Then, redeploy"
],
"metadata": {
"id": "YuW_wSXoZpfs"
}
},
{
"cell_type": "code",
"source": [
"!az webapp up"
],
"metadata": {
"id": "5QhwSa3jkeg_"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"Test again"
],
"metadata": {
"id": "7vaXHh5uiQW0"
}
},
{
"cell_type": "code",
"source": [
"print('http://' + APP_NAME + '.azurewebsites.net')"
],
"metadata": {
"id": "fia43a1UiPBt"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"Check logs"
],
"metadata": {
"id": "nALLBu0EZ2xh"
}
},
{
"cell_type": "code",
"source": [
"!az webapp log tail"
],
"metadata": {
"id": "6WY68oEjmwRn"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"🤚 **Stop the previous cell before continuing**"
],
"metadata": {
"id": "IaEds3PxinF0"
}
},
{
"cell_type": "markdown",
"source": [
"Clean up resources (takes some time)"
],
"metadata": {
"id": "WGWUCNhwZ_Oe"
}
},
{
"cell_type": "code",
"source": [
"!az group delete --yes"
],
"metadata": {
"id": "ieQ-EC9xoJKk"
},
"execution_count": null,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment