Below instruction is to setup backend to automatically upload the generated files in the android app to the Blob store.
- Search for Function App in the market place
- Click on create a function app, in the form that appears:
- Modify the prefilled fields if required.
- Fill in the azure function app name. Example: smartKcFunctions
- Choose runtime to be
Python
- Choose operating system as
Linux
- Click on
Next > Hosting
- Select a storage account or else create a new storage account if there is no existing storage account
- Click on
Review + Create
from top
Once, you have created a function app, you need to create a local environment to publish a new function under the created function app.
- The Azure Functions Core Tools version 4.x.
- Python versions that are supported by Azure Functions. For more information, see How to install Python.
- Visual Studio Code
- The Python extension for Visual Studio Code.
- The Azure Functions extension for Visual Studio Code, version 1.8.3 or a later version.
- Open a new empty folder with Visual Studio Code
- Choose the Azure icon in the Activity bar. Then in the
Workspace (local) area
, select the+
button - Choose
Create HTTP function
- Select
Python
when prompted for select a language. - Select
Skip virtual environment
when prompted for selecting interpreter path. - Name your Http function. For eg.
fileUploader
. - From the github repository, Under the folder
azure_function/uploader/smart_kc_test_uploader
copy filesfunction.json
andhost.json
and paste it to your respectivefunction.json
andhost.json
- Copy the above step with
azure_function/uploader/requirements.txt
and paste it to your respectiverequirements.txt
- Make sure the app runs by typing:
func start
in the terminal open insideazure_function/uploader
- Publish the function by running the command
func azure functionapp publish [YourFunctionAppName]
Certain variables need to be setup for the azure function. Follow these steps to set this up:
- Go to the Azure Function resource
- Click on the
Configuration
underSettings
section - Under
Application settings
tab click onNew application setting
- On the new dialogue box that appears, enter name of the variable as
upload_secret
and put in a strong secret. - Click
OK
to save the variable. - Click
Save
at the top to save the application settings. - Click
Continue
on the warning if it appears.
To upload files in the blob storage azure function needs certain permissions. Follow below steps to set it up.
- Go to your Azure function App.
- Click on
Identity
underSettings
- Under the
System Assigned
tab, turn theStatus
switch to On and clickSave
on the top. - After you click
Save
, Click the button that will appear asAdd Azure Role Assignments
. - On the new page that appears, Click
Add role Assignments
. - Next, select scope as
Storage
. Then, select a storage resource where you want the files to be uploaded. Further, select the role asBlob Storage Contributor role
- Click
Save
To get the URL of Azure function, go to the function app in your azure portal. Under Funcions
click the Azure function created by you and click on Get Function Url
present on the top.
- Open the android app and click on
UPDATE PREFS
. - Turn on the switch labelled as
Upload Enabled
- Enter Azure function URL on the
Upload URL
field. - Enter Uplaod Secret on the
Upload Secret
field. - Click
Save
Now, the app can be used to upload images, simply click onUpload Files
in the homescreen after clicking the images.