{"id":13421638,"url":"https://github.com/alejoar/Flask-Azure-Storage","last_synced_at":"2025-03-15T10:31:17.362Z","repository":{"id":57430140,"uuid":"54198955","full_name":"alejoar/Flask-Azure-Storage","owner":"alejoar","description":"Flask extension that provides integration with Azure Storage","archived":false,"fork":false,"pushed_at":"2018-04-13T14:10:51.000Z","size":11,"stargazers_count":22,"open_issues_count":1,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-03T01:35:15.036Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alejoar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-18T12:18:30.000Z","updated_at":"2025-02-13T00:25:02.000Z","dependencies_parsed_at":"2022-08-26T03:24:53.180Z","dependency_job_id":null,"html_url":"https://github.com/alejoar/Flask-Azure-Storage","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alejoar%2FFlask-Azure-Storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alejoar%2FFlask-Azure-Storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alejoar%2FFlask-Azure-Storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alejoar%2FFlask-Azure-Storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alejoar","download_url":"https://codeload.github.com/alejoar/Flask-Azure-Storage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243718914,"owners_count":20336590,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T23:00:27.506Z","updated_at":"2025-03-15T10:31:17.356Z","avatar_url":"https://github.com/alejoar.png","language":"Python","readme":"# Flask-Azure-Storage [![PyPI version](https://badge.fury.io/py/Flask-Azure-Storage.png)](https://badge.fury.io/py/Flask-Azure-Storage)\n\nA Flask extension that provides integration with Azure Storage\n\n**Table of Contents**\n\n- [Flask-Azure-Storage ](#flask-azure-storage-)\n\t- [Install](#install)\n\t- [Usage](#usage)\n\t- [Examples](#examples)\n\t\t- [Create container](#create-container)\n\t\t- [Delete container](#delete-container)\n\t\t- [Upload a file](#upload-a-file)\n\t\t- [Delete a file](#delete-a-file)\n\t\t- [Check if file exists](#check-if-file-exists)\n\t- [More examples](#more-examples)\n\t- [Seamless integration with Flask's static assets ('static' folder)](#seamless-integration-with-flasks-static-assets-static-folder)\n\n## Install\n\n```\npip install Flask-Azure-Storage\n```\n\n## Usage\n\nSet the account credentials in your [app.config](http://flask.pocoo.org/docs/0.10/config/):\n```python\nAZURE_STORAGE_ACCOUNT_NAME = \"your-account-name\"\nAZURE_STORAGE_ACCOUNT_KEY = \"your-account-key\"\n```\n\nInitialize the extension:\n```python\nfrom flask import Flask\nfrom flask.ext.azure_storage import FlaskAzureStorage\n\napp = Flask(__name__)\nazure_storage = FlaskAzureStorage(app)\n```\n\nOr, if you follow the [Flask application factory pattern](http://flask.pocoo.org/docs/0.10/patterns/appfactories/):\n```python\nfrom flask import Flask\nfrom flask.ext.azure_storage import FlaskAzureStorage\n\nazure_storage = FlaskAzureStorage()\n\ndef create_app(config):\n    app = Flask(__name__)\n    app.config.from_object(config)\n    # initialize azure storage on the app within create_app()\n    azure_storage.init_app(app)\n```\n\nFrom the `azure_storage` object you can now access any of the following classes:\n\n| Attribute \t\t\t\t\t\t| Class \t\t\t\t\t\t\t\t\t\t\t\t\t|\n| --------------------------------- | --------------------------------------------------------- |\n| azure_storage.account \t\t\t| azure.storage.cloudstorageaccount.CloudStorageAccount \t|\n| azure_storage.block_blob_service \t| azure.storage.blob.blockblobservice.BlockBlobService \t\t|\n| azure_storage.page_blob_service \t| azure.storage.blob.pageblobservice.PageBlobService \t\t|\n| azure_storage.append_blob_service | azure.storage.blob.appendblobservice.AppendBlobService \t|\n| azure_storage.queue_service \t\t| azure.storage.queue.queueservice.QueueService \t\t\t|\n| azure_storage.table_service \t\t| azure.storage.table.tableservice.TableService \t\t\t|\n| azure_storage.file_service \t\t| azure.storage.file.fileservice.FileService \t\t\t\t|\n\n\n## Examples\n\n#### Create container\n```python\nazure_storage.block_blob_service.create_container('container-name')\n```\n\n#### Delete container\n```python\nazure_storage.block_blob_service.delete_container('container-name')\n```\n\n#### Upload a file\n```python\nfrom azure.storage.blob import ContentSettings\nazure_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'))\n```\n\n#### Delete a file\n```python\nazure_storage.block_blob_service.delete_blob('container-name', 'uploaded-file-name')\n```\n\n#### Check if file exists\n```python\nazure_storage.block_blob_service.exists('container-name', 'uploaded-file-name')\n```\n\n## More examples\nThere are plenty more things you can do. For more examples, [check out the Azure Storage SDK for Python samples](https://github.com/Azure/azure-storage-python/tree/cb51c567c5bdc1192482c7fc96cc89dad4879a29/samples)\n\n## Seamless integration with Flask's static assets ('static' folder)\nAutomatically upload the static assets associated with a Flask application to Azure Storage.\n\nYou 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.\n\nThis feature is based on [flask-s3](https://github.com/e-dard/flask-s3), intending to implement similar functionality based on the Azure Storage service. It is still under development so please report any issues.\n\nTo upload all your static files first set the following parameters in the app.config:\n```python\nAZURE_STORAGE_ACCOUNT_NAME = \"your-account-name\"\nAZURE_STORAGE_ACCOUNT_KEY = \"your-account-key\"\nAZURE_STORAGE_CONTAINER_NAME = \"your-container-name\"  # make sure the container is created. Refer to the previous examples or to the Azure admin panel\nAZURE_STORAGE_DOMAIN = 'your-account-base-domain'\n```\n\nThen you can call the method `create_all` from the python interpreter:\n```python\n\u003e\u003e\u003e from flask import current_app\n\u003e\u003e\u003e from flask.ext.azure_storage import create_all\n\u003e\u003e\u003e create_all(current_app)\n```\n\nOr, a better choice (if you use something like FLask-Script):\n```python\napp = create_app(os.getenv('FLASK_CONFIG') or 'default')\nmanager = Manager(app)\n\n@manager.command\ndef deploy_azure():\n    from flask.ext.azure_storage import create_all\n    create_all(app)\n```\n\nSo now it is possible to simply call `python manage.py deploy_azure` to upload your assets.\n","funding_links":[],"categories":["Python","Other SDK","介绍"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falejoar%2FFlask-Azure-Storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falejoar%2FFlask-Azure-Storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falejoar%2FFlask-Azure-Storage/lists"}