Flask extension that provides integration with Azure Storage

Overview

Flask-Azure-Storage PyPI version

A Flask extension that provides integration with Azure Storage

Table of Contents

Install

pip install Flask-Azure-Storage

Usage

Set the account credentials in your app.config:

AZURE_STORAGE_ACCOUNT_NAME = "your-account-name"
AZURE_STORAGE_ACCOUNT_KEY = "your-account-key"

Initialize the extension:

from flask import Flask
from flask.ext.azure_storage import FlaskAzureStorage

app = Flask(__name__)
azure_storage = FlaskAzureStorage(app)

Or, if you follow the Flask application factory pattern:

from flask import Flask
from flask.ext.azure_storage import FlaskAzureStorage

azure_storage = FlaskAzureStorage()

def create_app(config):
    app = Flask(__name__)
    app.config.from_object(config)
    # initialize azure storage on the app within create_app()
    azure_storage.init_app(app)

From the azure_storage object you can now access any of the following classes:

Attribute Class
azure_storage.account azure.storage.cloudstorageaccount.CloudStorageAccount
azure_storage.block_blob_service azure.storage.blob.blockblobservice.BlockBlobService
azure_storage.page_blob_service azure.storage.blob.pageblobservice.PageBlobService
azure_storage.append_blob_service azure.storage.blob.appendblobservice.AppendBlobService
azure_storage.queue_service azure.storage.queue.queueservice.QueueService
azure_storage.table_service azure.storage.table.tableservice.TableService
azure_storage.file_service azure.storage.file.fileservice.FileService

Examples

Create container

azure_storage.block_blob_service.create_container('container-name')

Delete container

azure_storage.block_blob_service.delete_container('container-name')

Upload a file

from azure.storage.blob import ContentSettings
azure_storage.block_blob_service.create_blob_from_path(container_name='container-name', blob_name='uploaded-file-name', file_path='/path/to/your/file.png', content_settings=ContentSettings(content_type='image'))

Delete a file

azure_storage.block_blob_service.delete_blob('container-name', 'uploaded-file-name')

Check if file exists

azure_storage.block_blob_service.exists('container-name', 'uploaded-file-name')

More examples

There are plenty more things you can do. For more examples, check out the Azure Storage SDK for Python samples

Seamless integration with Flask's static assets ('static' folder)

Automatically upload the static assets associated with a Flask application to Azure Storage.

You don't need to manually change your url_for calls, Flask-Azure-Storage will automatically target Azure where you call url_for('static', ...) in your Jinja themes.

This feature is based on flask-s3, intending to implement similar functionality based on the Azure Storage service. It is still under development so please report any issues.

To upload all your static files first set the following parameters in the app.config:

AZURE_STORAGE_ACCOUNT_NAME = "your-account-name"
AZURE_STORAGE_ACCOUNT_KEY = "your-account-key"
AZURE_STORAGE_CONTAINER_NAME = "your-container-name"  # make sure the container is created. Refer to the previous examples or to the Azure admin panel
AZURE_STORAGE_DOMAIN = 'your-account-base-domain'

Then you can call the method create_all from the python interpreter:

>>> from flask import current_app
>>> from flask.ext.azure_storage import create_all
>>> create_all(current_app)

Or, a better choice (if you use something like FLask-Script):

app = create_app(os.getenv('FLASK_CONFIG') or 'default')
manager = Manager(app)

@manager.command
def deploy_azure():
    from flask.ext.azure_storage import create_all
    create_all(app)

So now it is possible to simply call python manage.py deploy_azure to upload your assets.

You might also like...
Azure Neural Speech Service TTS

Written in Python using the Azure Speech SDK. App.py provides an easy way to create an Text-To-Speech request to Azure Speech and download the wav file. Azure Neural Voices Text-To-Speech enables fluid, natural-sounding text to speech that matches the patterns and intonation of human voices.

 Herramienta para transferir eventos de Sucuri WAF hacia Azure Monitor Log Analytics.
Herramienta para transferir eventos de Sucuri WAF hacia Azure Monitor Log Analytics.

Transfiere eventos de Sucuri hacia Azure LogAnalytics Script para transferir eventos del Sucuri Web Application Firewall (WAF) hacia Azure LogAnalytic

Herramienta para transferir eventos de Sucuri WAF hacia Azure Data Tables.
Herramienta para transferir eventos de Sucuri WAF hacia Azure Data Tables.

Transfiere eventos de Sucuri hacia Azure Data Tables Script para transferir eventos del Sucuri Web Application Firewall (WAF) hacia Azure Data Tables,

Asyncio SDK for Azure Cosmos DB

Asyncio SDK for Azure Cosmos DB. This library is intended to be a very thin asyncio wrapper around the Azure Comsos DB Rest API. It is not intended to have feature parity with the Microsoft Azure SDKs but to provide async versions of the most commonly used interfaces.

Bot made with Microsoft Azure' cloud service
Bot made with Microsoft Azure' cloud service

IttenWearBot Autori: Antonio Zizzari Simone Giglio IttenWearBot è un bot intelligente dotato di sofisticate tecniche di machile learning che aiuta gli

First Party data integration solution built for marketing teams to enable audience and conversion onboarding into Google Marketing products (Google Ads, Campaign Manager, Google Analytics).

Megalista Sample integration code for onboarding offline/CRM data from BigQuery as custom audiences or offline conversions in Google Ads, Google Analy

Home Assistant custom integration for controlling Powered by Tuya (PBT) devices using Tuya Open API, officially maintained by the Tuya Developer Team.
Home Assistant custom integration for controlling Powered by Tuya (PBT) devices using Tuya Open API, officially maintained by the Tuya Developer Team.

Tuya Home Assistant Integration Home Assistant custom integration for controlling Powered by Tuya (PBT) devices using Tuya Open API, officially mainta

A Git Alert Bot - Github Integration for Pyrogram & Telethon

Yet Another GitAlertBot Inspired From @Pokurt's GitGram Run Bot: Local Host Git Clone Repo : For Telethon Version : git clone https://github.com/DevsE

 Discord Blogger Integration Using Blogger API
Discord Blogger Integration Using Blogger API

It's a very simple discord bot created in python using blogger api in order to search and send your website articles in your discord chat in form of an embedded message. It's pretty useful for people who are on the blogger platform as there are not much you can do with blogger because of the restrictions.

Comments
  • How to download data from container

    How to download data from container

    Hi

    I am trying to connect my flask python app to azure blob stroage. how do you connect to azure blob block or download files from bolb. which call to use?

    opened by ghost 0
Releases(0.2.1)
Owner
Alejo Arias
Software Engineer @ Dotdash
Alejo Arias
D(HE)ater is a security tool can perform DoS attack by enforcing the DHE key exchange.

D(HE)ater D(HE)ater is an attacking tool based on CPU heating in that it forces the ephemeral variant of Diffie-Hellman key exchange (DHE) in given cr

Balasys 138 Dec 15, 2022
Analyzed the data of VISA applicants to build a predictive model to facilitate the process of VISA approvals.

Analyzed the data of Visa applicants, built a predictive model to facilitate the process of visa approvals, and based on important factors that significantly influence the Visa status recommended a s

Jesus 1 Jan 08, 2022
基于nonebot2开发的群管机器人qbot,支持上传并运行python代码以及一些基础管理功能

nonebot2-Eleina 基于nonebot2开发的群管机器人qbot,支持上传并运行python代码以及一些基础管理功能 Readme 环境:python3.7.3+,go-cqhttp 安装及配置:参见(https://v2.nonebot.dev/guide/installation.h

1 Dec 06, 2022
AWS-serverless-starter - AWS Lambda serverless stack via Serverless framework

Serverless app via AWS Lambda, ApiGateway and Serverless framework Configuration

Bəxtiyar 3 Feb 02, 2022
Docker image for epicseven gvg qq chatbot based on Xunbot

XUN_Langskip XUN 是一个基于 NoneBot 和 酷Q 的功能型QQ机器人,目前提供了音乐点播、音乐推荐、天气查询、RSSHub订阅、使用帮助、识图、识番、搜番、上车、磁力搜索、地震速报、计算、日语词典、翻译、自我检查,权限等级功能,由于是为了完成自己在群里的承诺,一时兴起才做的,所

Xavier Xiong 2 Jun 08, 2022
Python version of PlaceNL's headless bot with automatic access token refresh

Reddit /r/place 2022 headless bot This headless Python bot will automatically login to reddit, obtain access tokens (and refreshes them when they expi

19 May 21, 2022
This is a unofficial library for making bots in rubika.

rubika this is a unofficial library for making bots in rubika using this library you can make your own0 rubika bot and control that those bots that ma

Bahman 50 Jan 02, 2023
A high level library for building Discord bots.

Qord A high level library for building Discord bots. 🚧 This library is currently in development. Questions that you are having What is this? This is

Izhar Ahmad 16 May 14, 2022
This is a small package to interact with the OpenLigaDB API.

OpenLigaDB This is a small package to interact with the OpenLigaDB API. Installation Run the following to install: pip install openligadb Usage from o

1 Dec 31, 2021
For Help/Questions Join in discord

Simple-Nitro-Generator-Source Must have installed python! Discord: $MartoBossX#7777 Server: https://discord.gg/ErynDxTV5Y DONATE: (Crypto) BTC: bc1qg8

1 Jan 08, 2022
PlexAutoSkip - Automatically skip content in Plex

PlexAutoSkip Automatically skip tagged content in Plex A background python scrip

Michael Higgins 97 Dec 21, 2022
With this program you can work English & Turkish

1 - How Can I Work This? You must have Python compilers in order to run this program. First of all, download the compiler in the link. Compiler 2 - Do

Mustafa Bahadır Doğrusöz 3 Aug 07, 2021
VideoMergeDcBot1 - Video Merge Dc Bot for telegram

VIDEO MERGE BOT An Telegram Bot Demo 👉 @VideoMergeDcBot To Merge multiple Video

Selfie SD 2 Feb 04, 2022
An attempt to escape the horrible JIRA editor.

An attempt to escape the horrible JIRA editor. jira_filter.py is a pandoc filter that cleans up some of JIRA's html so that it can be converted to Mar

Stefan Matting 2 Feb 10, 2022
CRUD database for python discord bot developers that stores data on discord text channels

Discord Database A CRUD (Create Read Update Delete) database for python Discord bot developers. All data is stored in key-value pairs directly on disc

Ankush Singh 7 Oct 22, 2022
A casino discord bot written in Python

Casino Bot Casino bot is a gambling discord bot I made for my friends. It is able to play blackjack, slots, flip a coin, and roll dice. It stores ever

Connor Swislow 27 Dec 30, 2022
Easy Google Translate: Unofficial Google Translate API

easygoogletranslate Unofficial Google Translate API. This library does not need an api key or something else to use, it's free and simple. You can eit

Ahmet Eren Odacı 9 Nov 06, 2022
pyDuinoCoin is a simple python integration for the DuinoCoin REST API, that allows developers to communicate with DuinoCoin Master Server

PyDuinoCoin PyDuinoCoin is a simple python integration for the DuinoCoin REST API, that allows developers to communicate with DuinoCoin Main Server. I

BackrndSource 6 Jul 14, 2022
Instagram Bot posting earthquakes with magnitude greater than or equal to 3.5.

Instagram Bot posting earthquakes with magnitude greater than or equal to 3.5

Alican Yüksel 4 Aug 22, 2022
WakeNote is a tool that hides notifications from you until you confirm you want to read them, with technology to help prevent the reading of depressing messages first thing in the morning.

By: Seanpm2001, Et; Al. Top README.md Read this article in a different language Sorted by: A-Z Sorting options unavailable ( af Afrikaans Afrikaans |

Sean P. Myrick V19.1.7.2 3 Oct 21, 2022