An Azure function app that reads and writes data to a blob (txt file) in Azure blob storage in Python.
This is a simple function app that executes every 15 minutes based on a Timer Trigger .
Each time the function app runs, a random number between 1 - 10 is generated only once. The number is then logged to the text file along with the time it was generated and a random word.
The Function checks if a number exists and generates it if it doesn't exist otherwise it skips the number.
- Azure Account
- Visual Studio Code with Azure Extension installed
- Connection String
- Container Name
- Blob Name
To clone the repository, open the terminal and paste the code below:
git clone https://github.com/Ndarugaa/Azure-Function-App-to-Read-and-Write-to-Blob-Storage.git
Open the cloned repository folder with Visual Studio code.
Login to your Azure Account
- Go to https://portal.azure.com/#home
- On the Left menu, Under Storage accounts
- Select an existing or create a new Storage Account.
The connection String is important for connecting your function app to the blob storage
- On the Storage Accounts Menu
- Under Security + Networking, Select Access Keys
- Under
Key1
orKey2
copy any of theconnection strings
- Paste the connection string to the
__init__.py
file, in theconnection string
variable inline 16
- In the
__init__.py
file- In line 17 change the
container name
variable to your desired container name.- In line 18, Change the
blob name
variable to the desired blob name
Note: The following characters are not allowed in container names: uppercase letters, spaces, and special characters such as #, %, and &
Ensure that you have the Azure extension
installed. Once VScode has opened, click on the Azure icon
.
On the Azure menu that appears, Right click on Function App
and Create a Function App in Azure
Pop-up questions to create the function appear at the top of the open Visual Studio code window.
Once the function app has been successfully created, Under the Workspace submenu, click on the function app icon
and then click Deploy to Function app
.
To check the status of your function app, open the Azure portal
,
under Function App, click on your Function App name.
Open the TimerTrigger
In the Function App menu that appears, click on Monitor
Notice that the function executes after every 15 minutes
. Read More Here