Giter Club home page Giter Club logo

datasette-on-azure's Introduction

Deploying Datasette using Azure Functions

This repository shows an example of Datasette deployed using Azure Functions.

https://azure-functions-datasette.azurewebsites.net/

It uses a slightly modified version of the ASGI proof of concept wrapper created by Anthony Shaw in this GitHub issues thread.

To deploy you'll need an Azure account, plus the az and func command-line tools. I installed these following the instructions in this tutorial - specifically this and this.

You'll need to create a resource group, a storage account and a function app.

I found that the resource group needed to be in westeurope for functions to work correctly.

Creating the resource group:

az group create \
    --name datasette-rg \
    --location westeurope

Creating the storage account:

az storage account create \
    --name datasettestorage \
    --location westeurope \
    --resource-group datasette-rg \
    --sku Standard_LRS

Creating the function app. The name here is the name that will be exposed in the default URL, so it needs to be globally unique - unlike the storage account and resource group which only have to be unique within your Azure account

az functionapp create \
    --resource-group datasette-rg \
    --consumption-plan-location westeurope \
    --runtime python \
    --runtime-version 3.10 \
    --functions-version 4 \
    --storage-account datasettestorage \
    --os-type linux \
    --name azure-functions-datasette

In Simon's original draft, there's an explicit publish step, but with Functions version 4 it looks like that might no longer be necessary? Well I'm up and running at https://azure-functions-datasette.azurewebsites.net/ in any case now.

curl https://azure-functions-datasette.azurewebsites.net/

Will return tomorrow to keep at it.

===

We'll need both az and func for this next part.

These commmands will fill loca.settings.json with the right stuff to get started.

func azure functionapp fetch-app-settings azure-functions-datasette
func azure storage fetch-connection-string datasettestorage

We get a "referenced bundle does not meet required minimum version" error, and this means we need to change something in host.json.

... Gah, now func start works but we're getting a bunch of errors. Seems like we'll need a venv.

python -m venv venv
source venv/bin/activate

... close... I think I need to install the things in requirements.txt as well. We can use pipenv for that.

# If you're on Ubuntu, remove the apt version, it's way too old
# and will probably throw a weird mutablemapping error
sudo apt remove pipenv
pip install pipenv

pipenv install
pipenv shell

func start

Hell yeah! No errors!!

Finally let's publish it.

func azure functionapp publish azure-functions-datasette

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.