从Amazon S3到Azure存储(Django的web应用程序)迁移 [英] Migrating from Amazon S3 to Azure Storage (Django web app)

查看:459
本文介绍了从Amazon S3到Azure存储(Django的web应用程序)迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我保持这样的Django的web应用程序,用户聚集,并相互聊天。如果他们想,他们也可以张贴图片。我处理这些照片(即优化其大小),并将其存储在Amazon S3桶(如在Azure存储一个容器)。要做到这一点,我成立了亚马逊桶中,并在包括以下配置code我的 settings.py

  DEFAULT_FILE_STORAG​​E ='storages.backends.s3boto.S3BotoStorage
AWS_S3_FORCE_HTTP_URL = TRUE
AWS_QUERYSTRING_AUTH =假
AWS_SECRET_ACCESS_KEY = os.environ.get('awssecretkey')
AWS_ACCESS_KEY_ID = os.environ.get('awsaccesskeyid')
AWS_S3_CALLING_FORMAT ='boto.s3.connection.OrdinaryCallingFormat
AWS_STORAG​​E_BUCKET_NAME ='damadam.in

此外博托2.38.0 Django的货仓1.1.8 安装在我的虚拟环境。 宝途是一个Python包,提供接口,亚马逊网络服务,而 Django的存储器是Django的自定义存储后端的集合。

我现在要停止使用Amazon S3的,而是迁移到 Azure存储。即我需要所有的现有文件从S3迁移到Azure存储以及接下来,我需要配置我的Django应用程序,以节省Azure存储所有新的静态资产。

我找不到我想要达到precise文档。虽然我知道的 Django的存储器 支持Azure的。有没有人做过这种之前迁移,并能指出我需要开始,什么步骤来得到一切正常运行?

注:向我要详细信息,如果您需要它


解决方案

每我的经验,你可以做两步从Amazon S3的迁移到Azure存储Django的web应用程序。

第一步是从S3的所有文件移动到的Azure Blob存储。有两种方法可以尝试。


  1. 使用的S3和Azure存储的工具,从S3移动文件到本地目录的Azure Blob存储。

这些工具下面的S3可以帮助将文件移动到本地目录。

有关本地文件迁移到Azure的Blob存储,您可以使用AzCo​​py命令行实用程序的高性能上传,下载和复制数据和从微软Azure斑点,文件和表存储,请参阅文件< A HREF =htt​​ps://azure.microsoft.com/en-us/documentation/articles/storage-use-azcopy/相对=nofollow> https://azure.microsoft.com/en-us/documentation /用品/存储的用azcopy / 。

例如: AzCopy /来源:C:\\ MyFolder文件/Dest:https://myaccount.blob.core.windows.net/mycontainer

<醇开始=2>
  • 通过在如Python,Java等请参考他们的API使用文档<熟悉的语言与Amazon S3和Azure的Blob存储的API编程迁移href=\"https://azure.microsoft.com/en-us/documentation/articles/storage-python-how-to-use-blob-storage/\" rel=\"nofollow\">https://azure.microsoft.com/en-us/documentation/articles/storage-python-how-to-use-blob-storage/和 http://docs.aws.amazon.com/AmazonS3/latest/ API / APIRest.html

  • 第二步是继文档的http:// Django的存储器.readthedocs.org / EN /最新/后端/ azure.html 重新配置的Django settings.py 文件。 Django的存储器将让你做任何上传到自动存储在您的存储容器中。

      DEFAULT_FILE_STORAG​​E ='storages.backends.azure_storage.AzureStorage
    AZURE_ACCOUNT_NAME ='我的账户'
    AZURE_ACCOUNT_KEY ='account_key
    AZURE_CONTAINER ='myContainer中'

    作为@neolursa说你可以找到关于Azure的门户网站这些设置。


    修改
    在Azure门户老:

    在Azure的新门户:

    I maintain this Django web app where users congregate and chat with one another. They can post pictures too if they want. I process these photos (i.e. optimize their size) and store them on an Amazon S3 bucket (like a 'container' in Azure Storage). To do that, I set up the bucket on Amazon, and included the following configuration code in my settings.py:

    DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
    AWS_S3_FORCE_HTTP_URL = True
    AWS_QUERYSTRING_AUTH = False
    AWS_SECRET_ACCESS_KEY = os.environ.get('awssecretkey')
    AWS_ACCESS_KEY_ID = os.environ.get('awsaccesskeyid')
    AWS_S3_CALLING_FORMAT='boto.s3.connection.OrdinaryCallingFormat'
    AWS_STORAGE_BUCKET_NAME = 'damadam.in'
    

    Additionally Boto 2.38.0 and django-storages 1.1.8 are installed in my virtual environment. Boto is a Python package that provides interfaces to Amazon Web Services, whereas django-storages is a collection of custom storage backends for Django.

    I now want to stop using Amazon S3 and instead migrate to Azure Storage. I.e. I need to migrate all existing files from S3 to Azure Storage, and next I need to configure my Django app to save all new static assets on Azure Storage.

    I can't find precise documentation on what I'm trying to achieve. Though I do know django-storages support Azure. Has anyone done this kind of a migration before, and can point out where I need to begin, what steps to follow to get everything up and running?

    Note: Ask me for more information if you need it.

    解决方案

    Per my experience, you can do the two steps for migrating from Amazon S3 to Azure Storage for Django web app.

    The first step is moving all files from S3 to Azure Blob Storage. There are two ways you can try.

    1. Using the tools for S3 and Azure Storage to move files from S3 to local directory to Azure Blob Storage.

    These tools below for S3 can help moving files to local directory.

    For moving local files to Azure Blob Storage, you can use AzCopy Command-Line Utility for high-performance uploading, downloading, and copying data to and from Microsoft Azure Blob, File, and Table storage, please refer to the document https://azure.microsoft.com/en-us/documentation/articles/storage-use-azcopy/.

    Example: AzCopy /Source:C:\myfolder /Dest:https://myaccount.blob.core.windows.net/mycontainer

    1. Migrating by programming with Amazon S3 and Azure Blob Storage APIs in your familiar language like Python, Java, etc. Please refer to their API usage docs https://azure.microsoft.com/en-us/documentation/articles/storage-python-how-to-use-blob-storage/ and http://docs.aws.amazon.com/AmazonS3/latest/API/APIRest.html.

    The second step is following the document http://django-storages.readthedocs.org/en/latest/backends/azure.html to re-configure Django settings.py file. Django-storages would allow any uploads you do to be automatically stored in your storage container.

    DEFAULT_FILE_STORAGE='storages.backends.azure_storage.AzureStorage'
    AZURE_ACCOUNT_NAME='myaccount'
    AZURE_ACCOUNT_KEY='account_key'
    AZURE_CONTAINER='mycontainer'
    

    You can find these settings on Azure Portal as @neolursa said.


    Edit: On Azure old portal:

    On Azure new portal:

    这篇关于从Amazon S3到Azure存储(Django的web应用程序)迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆