Deploy OkPy to Azure PaaS

Published 03-21-2019 02:27 PM 260 Views
Microsoft
First published on MSDN on Feb 13, 2019

Automate Grading & Personalize Feedback.

OK autogrades programming assignments, facilitates submission, composition feedback, and analytics for your class.

View a Demo of OkPy

The ok.py server collects submissions and displays analysis of student progress based on logging sent from client scripts the ok.py software was developed for CS 61A at UC Berkeley and is now used in numerous institutions around the world for autograding and assessment of Students.

Deploying Okpy on Azure

You can deploy Ok.py to Azure tenant using the deploy to Azure Script on this page.

In a production environment you may wish to customize these templates to share resources between environments and to adjust resource sizing. For example you may wish to use a single mySQL server with multiple databases, rather than one server per environment.

The provided templates deploy everything within the Resource Group outlined below. Items outside the resource group are an indication as to how Ok.py can integrate with additional Azure services:

Setup

Prior to deploying the template the terms and conditions for SendGrid must be accepted.

Using PowerShell:

Get-AzureRmMarketplaceTerms -Publisher "sendgrid" -Product "sendgrid_azure" -Name "free" | Set-AzureRmMarketplaceTerms -Accept

If you do not have access to PowerShell this can be run in the cloud shell via the Azure Portal.

Next, you'll need to create a Service Principal following the instructions here . The Service Principal is a credential to your Azure subscription that will enable the OKpy deployment to create Azure resources on your behalf.

Finally, grant read permissions to your Azure Container Registry instance to the Service Principal. This will enable the OKpy deployment to access Docker images for okpy and autopy in your registry and deploy them to the infrastructure set up by the template:

SP_APP_ID=<insert the app id of your okpy service principal here>
ACR_NAME=<insert name of your container registry here>
RESOURCE_GROUP=<insert the resource group of your container registry here>

az role assignment create \
--assignee "${SP_APP_ID}" \
--role Reader \
--scope "$(az acr show --name "${ACR_NAME}" --resource-group "${ACR_RESOURCE_GROUP}" --query "id" --output tsv)"
Deployment

To deploy Ok.py to Azure use the deploy button below. If you are not familiar with the configuration of Azure resources please check our integration guide .


You can also run the deployment locally:

mkdir -p azure/paas/secrets
docker build -t ok-setup azure/paas
docker run -v $PWD/azure/paas/secrets:/app/secrets ok-setup

Note that the deployment can take upwards of 30 minutes to complete. After the deployment is done, remember to update your Active Directory application to include https://<app-name>.<location>.cloudapp.azure.com/login/authorized/ as a redirect URL.

If your interested in learning more about OKpy on Azure see https://github.com/okpy/ok/tree/master/azure

%3CLINGO-SUB%20id%3D%22lingo-sub-381459%22%20slang%3D%22en-US%22%3EDeploy%20OkPy%20to%20Azure%20PaaS%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-381459%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3E%20First%20published%20on%20MSDN%20on%20Feb%2013%2C%202019%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CH3%20id%3D%22toc-hId-1512867077%22%20id%3D%22toc-hId-1484118763%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F96623i8A0B0B972062DA87%22%20%2F%3E%3C%2FH3%3E%0A%20%20%3CH3%20id%3D%22toc-hId--1039289884%22%20id%3D%22toc-hId--1068038198%22%3EAutomate%20Grading%20%26amp%3B%20Personalize%20Feedback.%3C%2FH3%3E%0A%20%20%3CP%3EOK%20autogrades%20programming%20assignments%2C%20facilitates%20submission%2C%20composition%20feedback%2C%20and%20analytics%20for%20your%20class.%3C%2FP%3E%0A%20%20%3CP%3E%3CA%3EView%20a%20Demo%20%3C%2FA%3E%20of%20OkPy%3C%2FP%3E%0A%20%20%3CP%3EThe%20ok.py%20server%20collects%20submissions%20and%20displays%20analysis%20of%20student%20progress%20based%20on%20logging%20sent%20from%20client%20scripts%20the%20ok.py%20software%20was%20developed%20for%20CS%2061A%20at%20UC%20Berkeley%20and%20is%20now%20used%20in%20numerous%20institutions%20around%20the%20world%20for%20autograding%20and%20assessment%20of%20Students.%3C%2FP%3E%0A%20%20%3CP%3EDeploying%20Okpy%20on%20Azure%3C%2FP%3E%0A%20%20%3CP%3EYou%20can%20deploy%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fokpy%2Fok%2Fblob%2Fmaster%2Fazure%2Fpaas%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20Ok.py%20%3C%2FA%3E%20to%20Azure%20tenant%20using%20the%20deploy%20to%20Azure%20Script%20on%20this%20page.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20In%20a%20production%20environment%20you%20may%20wish%20to%20customize%20these%20templates%20to%20share%20resources%20between%20environments%20and%20to%20adjust%20resource%20sizing.%20For%20example%20you%20may%20wish%20to%20use%20a%20single%20mySQL%20server%20with%20multiple%20databases%2C%20rather%20than%20one%20server%20per%20environment.%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F96624i07BA64FF9F7476B7%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EThe%20provided%20templates%20deploy%20everything%20within%20the%20Resource%20Group%20outlined%20below.%20Items%20outside%20the%20resource%20group%20are%20an%20indication%20as%20to%20how%20Ok.py%20can%20integrate%20with%20additional%20Azure%20services%3A%3C%2FP%3ESetup%3CP%3EPrior%20to%20deploying%20the%20template%20the%20terms%20and%20conditions%20for%20SendGrid%20must%20be%20accepted.%3C%2FP%3E%0A%20%20%3CP%3EUsing%20PowerShell%3A%3C%2FP%3E%0A%20%20%3CCODE%3E%0A%20%20%20Get-AzureRmMarketplaceTerms%20-Publisher%20%22sendgrid%22%20-Product%20%22sendgrid_azure%22%20-Name%20%22free%22%20%7C%20Set-AzureRmMarketplaceTerms%20-Accept%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%3C%2FCODE%3E%0A%20%20%3CP%3E%0A%20%20%20If%20you%20do%20not%20have%20access%20to%20PowerShell%20this%20can%20be%20run%20in%20the%20cloud%20shell%20via%20the%20Azure%20Portal.%0A%20%20%3C%2FP%3E%0A%20%20%3CP%3E%0A%20%20%20Next%2C%20you'll%20need%20to%20create%20a%20Service%20Principal%20following%20the%20instructions%0A%20%20%20%3CA%20href%3D%22https%3A%2F%2Faka.ms%2Fcreate-sp%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%0A%20%20%20%20here%0A%20%20%20%3C%2FA%3E%0A%20%20%20.%20The%20Service%20Principal%20is%20a%20credential%20to%20your%20Azure%20subscription%20that%20will%20enable%20the%20OKpy%20deployment%20to%20create%20Azure%20resources%20on%20your%20behalf.%0A%20%20%3C%2FP%3E%0A%20%20%3CP%3E%0A%20%20%20Finally%2C%20grant%20read%20permissions%20to%20your%20Azure%20Container%20Registry%20instance%20to%20the%20Service%20Principal.%20This%20will%20enable%20the%20OKpy%20deployment%20to%20access%20Docker%20images%20for%20okpy%20and%20autopy%20in%20your%20registry%20and%20deploy%20them%20to%20the%20infrastructure%20set%20up%20by%20the%20template%3A%0A%20%20%3C%2FP%3E%0A%20%20%3CCODE%3E%0A%20%20%20SP_APP_ID%3D%3CINSERT%20the%3D%22%22%20app%3D%22%22%20id%3D%22%22%20of%3D%22%22%20your%3D%22%22%20okpy%3D%22%22%20service%3D%22%22%20principal%3D%22%22%20here%3D%22%22%3E%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20ACR_NAME%3D%3CINSERT%20name%3D%22%22%20of%3D%22%22%20your%3D%22%22%20container%3D%22%22%20registry%3D%22%22%20here%3D%22%22%3E%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20RESOURCE_GROUP%3D%3CINSERT%20the%3D%22%22%20resource%3D%22%22%20group%3D%22%22%20of%3D%22%22%20your%3D%22%22%20container%3D%22%22%20registry%3D%22%22%20here%3D%22%22%3E%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20az%20role%20assignment%20create%20%5C%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20--assignee%20%22%24%7BSP_APP_ID%7D%22%20%5C%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20--role%20Reader%20%5C%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20--scope%20%22%24(az%20acr%20show%20--name%20%22%24%7BACR_NAME%7D%22%20--resource-group%20%22%24%7BACR_RESOURCE_GROUP%7D%22%20--query%20%22id%22%20--output%20tsv)%22%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%3C%2FINSERT%3E%3C%2FINSERT%3E%3C%2FINSERT%3E%3C%2FCODE%3E%0A%20%20Deployment%0A%20%20%3CP%3E%0A%20%20%20To%20deploy%0A%20%20%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fokpy%2Fok%2Fblob%2Fmaster%2Fazure%2Fpaas%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%0A%20%20%20%20Ok.py%0A%20%20%20%3C%2FA%3E%0A%20%20%20to%20Azure%20use%20the%20deploy%20button%20below.%20If%20you%20are%20not%20familiar%20with%20the%20configuration%20of%20Azure%20resources%20please%20check%20our%0A%20%20%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fokpy%2Fok%2Fblob%2Fmaster%2Fazure%2FREADME.md%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%0A%20%20%20%20integration%20guide%0A%20%20%20%3C%2FA%3E%0A%20%20%20.%0A%20%20%3C%2FP%3E%0A%20%20%3CP%3E%0A%20%20%20%3CA%20href%3D%22https%3A%2F%2Fportal.azure.com%2F%23create%2FMicrosoft.Template%2Furi%2Fhttps%253A%252F%252Fraw.githubusercontent.com%252Fokpy%252Fok%252Fmaster%252Fazure%252Fpaas%252Farm%252Fazure.deploy.json%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%0A%20%20%20%20%3C%2FA%3E%3C%2FP%3E%3CP%3E%0A%20%20%20%20%20%3CBR%20%2F%3E%0A%20%20%20%20%3C%2FP%3E%0A%20%20%20%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E%0A%20%20%20You%20can%20also%20run%20the%20deployment%20locally%3A%0A%20%20%3C%2FP%3E%0A%20%20%3CCODE%3E%0A%20%20%20mkdir%20-p%20azure%2Fpaas%2Fsecrets%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20docker%20build%20-t%20ok-setup%20azure%2Fpaas%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20docker%20run%20-v%20%24PWD%2Fazure%2Fpaas%2Fsecrets%3A%2Fapp%2Fsecrets%20ok-setup%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%3C%2FCODE%3E%0A%20%20%3CP%3E%0A%20%20%20Note%20that%20the%20deployment%20can%20take%20upwards%20of%2030%20minutes%20to%20complete.%20After%20the%20deployment%20is%20done%2C%20remember%20to%20update%20your%20Active%20Directory%20application%20to%20include%0A%20%20%20%3CCODE%3E%0A%20%20%20%20https%3A%2F%2F%3CAPP-NAME%3E.%3CLOCATION%3E.cloudapp.azure.com%2Flogin%2Fauthorized%2F%0A%20%20%20%3C%2FLOCATION%3E%3C%2FAPP-NAME%3E%3C%2FCODE%3E%0A%20%20%20as%20a%20redirect%20URL.%0A%20%20%3C%2FP%3E%0A%20%20%3CP%3E%0A%20%20%20If%20your%20interested%20in%20learning%20more%20about%20OKpy%20on%20Azure%20see%0A%20%20%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fokpy%2Fok%2Ftree%2Fmaster%2Fazure%22%20title%3D%22https%3A%2F%2Fgithub.com%2Fokpy%2Fok%2Ftree%2Fmaster%2Fazure%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%0A%20%20%20%20https%3A%2F%2Fgithub.com%2Fokpy%2Fok%2Ftree%2Fmaster%2Fazure%0A%20%20%20%3C%2FA%3E%0A%20%20%3C%2FP%3E%0A%20%0A%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-381459%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20MSDN%20on%20Feb%2013%2C%202019%20Automate%20Grading%20%26amp%3B%20Personalize%20Feedback.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-381459%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Eacademic%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Ecloud%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EData%20Science%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Efaculty%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Elearning%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Eok%20py%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Estudent%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Version history
Last update:
‎Mar 21 2019 02:27 PM
Updated by: