Deployment of a Simian Web App involves 4 main steps:
- Get the code (this repo)
- Deploy your Simian Web App Python code as a web service on a(ny) backend.
Azure offers convenient & free hosting Python code as a web service. Deployment of the code can be done from within Visual Studio Code or directly from GitHub by means of GitHub Actions.
This GitHub project, when linked to your Azure Function, automates deployment of Python based Simian Web Apps on Azure.
Setting up deployment from GitHub to Azure Function can be done in several ways. This project describes the steps using the Azure Portal.
Once set up, updates to your code pushed to GitHub will be automatically deployed to your azurewebsites.net web service.This way Simian Web App functionality is exposed as a web service.
Source code is under your control and not shared with simiansuite.com. - Publish the app on Simian Portal
For evaluation purposes, a shared Simian Evaluation Portal where you can configure your own Simian Web App is readily available. - Use your app, live on the web
- Azure Functions build and deploy information is provided in
.github/workflows/main_my-simian-app.yml
. - Python package installation instructions are provided through
requirements.txt
. - Azure Function routing and generation of Simian specific startup information in logs is done in
function_app.py
. - Azure function type and authorization level is set in
function.json
- Simian Web Apps are placed in the
apps
folder.
A basic Simian Web App hello-world.py
example is included in this repository in the apps
directory.
The endpoint to this is example is https://YOUR_SUBDOMAIN.azurewebsites.net/api/hello-world
Additional Simian Web App(s) by adding your Simian Web App module to the apps
directory.
It is recommended to name your module in lower case chracters and underscores when needed.
The route will be the base name of your module .py
file with underscores (_
) replaced by dashes (-
).
The endpoint to a module called my_first_simian_app.py
stored in the apps
folder would be https://YOUR_SUBDOMAIN..azurewebsites.net/api/my-first-simian-app
Fork this repository on GitHub such that you can set it up to build and deploy changes to your own Azure Function.
If you are new to Azure you will need to create a (free) Azure account.
- Create a new Azure Function
(A free option is opted for below.)
Click "Select"
- Enter your Function App name, choose Python for Runtime stack, and a region near you.
- Navigate to the "Deployment" tab
Enable "Continuous deployment"
Select your Github account, organization, repository, and branch.
Enable "Basic authentication" (otherwise the publish profile will not contain credentials and pushing changes from GitHub will not work)
Click "Review + create"
- Click "Create" & and wait for deployment to complete.
- Click "Go to resource".
Take note of the URL of the Azure Function. - Click "Get publish profile" and store this publish profile in a secret in your GitHub repository:
Under your GitHub repository navigate toSettings > Security > Secrets and variables > Actions
Under the Secrets tab click "New repository secret"
Name:AZURE_FUNCTIONAPP_PUBLISH_PROFILE
Secret: [the_content_of_the_downloaded_publish_profile_file]
Click "Add secret" - To test if deployment from GitHub is working, in your Azure Portal, under your Azure Function "Deployment Center" you can click the "Sync" button.
In your GitHub Repository you can see the deployment activity and its success or failure under "Actions".
If successful, in your Azure Portal you should see "Status: Running" in theOverview page of your Azure Function.
Alternatively, you can clone this repository, locally create an Azure Function and deploy code changes from within Microsoft Visual Studio. See Develop Azure Functions by using Visual Studio Code
Azure Functions allow different authorization levels. In this repository the default is "anonymous" as set in the function.json
file.
Change "anonymous" to "function" to require an App key to access the Azure Function.
For usage from Simian Portal a header x-functions-key
should be set to the value of one of the "App keys" under "Functions" of your Azure Function in Azure Portal. See Azure Functions - Access key authorization
Depending on your (free) Azure plan, Azure Functions may spin down after some period of inactivity. When starting the Simian Web App after such period of inactivity it needs to be spinned up causing a delay.
Consider upgrading to a paid Azure plan to avoid spinning down.
Publishing your Simian Web App:
- Sign up at Simian Evaluation Portal.
(On the evaluation portal your app will only be accessible to you.)
When signed in you will see the Publish app.
- From your Azure deployment, take note of:
The subdomain of your backend deployment under .azurewebsites.net
The App key (if enabled on your Azure Function) - In Simian Evaluation Portal, configure and publish app here.
To configure the includedhello_world.py
app, set:Subdomain
to the subdomain of your.azurewebsites.net
web service.
(Subdomain isabc
if your webservice runs onabc.azurewebsites.net
.)Route
to the route to the module under theapps
directory that you want to deploy:hello-world
forhello_world.py
.
(Route to module is module file name without.py
, and with_
replaced by-
.)- Optionally, when authentication level is set to function on your Azure Function,
API Key
to the value of one of the App keys under Function in the Azure Portal under your Azure Function.
Then set the title, description, and image to be displayed on the tile representing your app in the portal.
Simian Portal supports app sharing and access management. Access to your app on Simian Evaluation Portal is restricted to yourself only, and solely serves evaluation purposes.
Contact simiansuite.com for Simian Portal cloud, and on-premises options.
Simian Portal works with a range of backend platforms from docker to Azure, and other cloud providers. For evaluation purposes render.com and Azure Functions have been chosen because of convenient deployment paths from code on GitHub to a live web service, its free entry offering and paid upgrade path, and last but not least because your code remains under your control.
Start your app via Simian Evaluation Portal.
You can bookmark your app URL for direct access.
The bookmark URL must not contain the
?tab_uuid=...
parameter becausetab_uuid
identifies a specific instance of the app which is cleared when closing the app.