Skip to content

Orchard ships with providers for Microsoft Azure Blob Storage, allowing Orchard to use Microsoft Azure Blob Storage as the underlying file system implementation for shell settings (Settings.txt) and/or media storage. This topic describes how to configure and enable this functionality.

Orchard附带Microsoft Azure Blob Storage提供程序,允许Orchard使用Microsoft Azure Blob Storage作为shell设置(Settings.txt)和/或媒体存储的底层文件系统实现。本主题介绍如何配置和启用此功能。

Using shell settings storage

使用shell设置存储

Storing shell settings in Microsoft Azure Blob Storage is useful when running Orchard in server farm where there is no shared file system storage. Microsoft Azure Cloud Services is an example of this. For this reason, when deploying Orchard to a Microsoft Azure Cloud Service using the Orchard.Azure.sln solution, the resulting package is already preconfigured to store shell settings in Microsoft Azure Blob Storage.

在没有共享文件系统存储的服务器场中运行Orchard时,在Microsoft Azure Blob存储中存储shell设置非常有用。 Microsoft Azure云服务就是一个例子。因此,在使用“Orchard.Azure.sln”解决方案将Orchard部署到Microsoft Azure云服务时,生成的软件包已预先配置为在Microsoft Azure Blob存储中存储shell设置。

The only thing you need to change before deploying is the connection string of the storage account you want to use:

在部署之前,您唯一需要更改的是您要使用的存储帐户的连接字符串:

  1. Open Orchard.Azure.sln.

1.打开Orchard.Azure.sln

  1. Navigate to Orchard.Azure.CloudService, double click the role Orchard.Azure.Web to bring up its property page, and navigate to the Settings tab.

2.导航到Orchard.Azure.CloudService,双击角色Orchard.Azure.Web打开其属性页面,然后导航到 Settings 选项卡。

  1. Set the Orchard.Azure.Settings.StorageConnectionString setting to be the connection string of the storage account you want to use.

3.将Orchard.Azure.Settings.StorageConnectionString设置为要使用的存储帐户的连接字符串。

  1. Deploy the cloud service.

4.部署云服务。

NOTE: It is not necessary to use this feature when running Orchard in a Microsoft Azure Web Site, because in this environment the file system is shared among instances.

注意:在Microsoft Azure网站中运行Orchard时,使用此功能不是必需的,因为在此环境中,文件系统在实例之间共享。

It is also possible to use this feature is any other hosting environment where you have a server farm with multiple nodes but no shared file system. To do this you need to do the following:

也可以在任何其他托管环境中使用此功能,其中您有一个具有多个节点但没有共享文件系统的服务器场。为此,您需要执行以下操作:

  • Add the Orchard.Azure.Settings.StorageConnectionString setting in the <appSettings> element of your Web.config file and set it to the connection string of the storage account you want to use.

  • Web.config文件的<appSettings>元素中添加Orchard.Azure.Settings.StorageConnectionString设置,并将其设置为您要使用的存储帐户的连接字符串。 *

  • Configure Autofac to load the AzureBlobShellSettingsManager implementation in your Config\Host.config file.

  • 配置Autofac以在Config \\ Host.config文件中加载AzureBlobShellSettingsManager实现。 *

Here's an example Config\Host.config configuration:

这是一个示例Config \\ Host.config配置:

<autofac defaultAssembly="Orchard.Framework">

    <components>

        <!-- Configure Orchard to store shell settings in Microsoft Azure Blob Storage. -->

        <component instance-scope="single-instance" type="Orchard.FileSystems.Media.ConfigurationMimeTypeProvider, Orchard.Framework" service="Orchard.FileSystems.Media.IMimeTypeProvider"></component>

        <component instance-scope="single-instance" type="Orchard.Azure.Services.Environment.Configuration.AzureBlobShellSettingsManager, Orchard.Azure" service="Orchard.Environment.Configuration.IShellSettingsManager"></component>

    </components>

</autofac>

Using Microsoft Azure Media Storage

使用Microsoft Azure媒体存储

The Microsoft Azure Media Storage feature in the Orchard.Azure module configures Orchard to use Microsoft Azure Blob Storage is the underlying file system implementation for storing media:

“Orchard.Azure”模块中的 Microsoft Azure Media Storage 功能将Orchard配置为使用Microsoft Azure Blob Storage是用于存储媒体的基础文件系统实现:

Orchard.Azure:

    Name: Microsoft Azure Media Storage

    Description: Activates an Orchard media storage provider that targets Microsoft Azure Blob Storage.

    Category: Hosting

There are two main reasons to use this feature:

使用此功能有两个主要原因:

  • Running Orchard in a server farm configuration. Without using some form of shared storage, media content will become out of sync between the nodes in your farm as users add or remove media files.

  • 在服务器场配置中运行Orchard。如果不使用某种形式的共享存储,则当用户添加或删除媒体文件时,媒体内容将在服务器场中的节点之间变得不同步。 *

  • Offloading media requests from the Orchard web server. When Microsoft Azure Media Storage is enabled all end user requests for media content are made directly to the public blob storage endpoint.

  • 从Orchard Web服务器卸载媒体请求。启用 Microsoft Azure Media Storage 后,所有最终用户对媒体内容的请求都将直接发送到公共Blob存储端点。

Enabling for Microsoft Azure Cloud Services

启用Microsoft Azure云服务

Before the feature can be enabled you must configure the connection string to the storage account you want to use. When running Orchard in a Microsoft Azure Cloud Service this can be done either before deploying (in the cloud service project) or after deploying (in the Microsoft Azure management portal).

在启用该功能之前,必须将连接字符串配置为要使用的存储帐户。在Microsoft Azure云服务中运行Orchard时,可以在部署之前(在云服务项目中)或部署之后(在Microsoft Azure管理门户中)完成。

To configure the connection string before deploying:

要在部署之前配置连接字符串

  1. Open Orchard.Azure.sln.

1.打开Orchard.Azure.sln

  1. Navigate to Orchard.Azure.CloudService, double click the role Orchard.Azure.Web to bring up its property page, and navigate to the Settings tab.

2.导航到Orchard.Azure.CloudService,双击角色Orchard.Azure.Web打开其属性页面,然后导航到 Settings 选项卡。

  1. Set the Orchard.Azure.Media.StorageConnectionString setting to be the connection string of the storage account in which you want to store media content.

3.将“Orchard.Azure.Media.StorageConnectionString”设置设置为要在其中存储媒体内容的存储帐户的连接字符串。

  1. Deploy the cloud service.

4.部署云服务。

To configure the connection string after deploying:

要在部署后配置连接字符串

  1. Deploy the cloud service.

1.部署云服务。

  1. In the management portal, navigate to your cloud service and select the Configure tab.

2.在管理门户中,导航到您的云服务,然后选择 Configure 选项卡。

  1. Under Orchard.Azure.Web locate the setting Orchard.Azure.Media.StorageConnectionString.

2.在Orchard.Azure.Web下找到设置Orchard.Azure.Media.StorageConnectionString

  1. Set it to be the connection string of the storage account in which you want to store media content.

3.将其设置为要在其中存储媒体内容的存储帐户的连接字符串。

  1. Click Save.

4.单击保存

You can now enable the feature Microsoft Azure Media Storage in the admin dashboard.

您现在可以在管理仪表板中启用功能 Microsoft Azure Media Storage

NOTE: For multi-tenancy scenarios the Orchard.Azure.Media.StorageConnectionString setting can optionally be prefixed with a tenant name.

注意:对于多租户方案,“Orchard.Azure.Media.StorageConnectionString”设置可以选择以租户名称为前缀。

Enabling for Microsoft Azure Web Sites

启用Microsoft Azure网站

Before the feature can be enabled you must configure the connection string to the storage account you want to use. When running Orchard in a Microsoft Azure Web Site this can be done either before deploying (in Web.config) or after deploying (in the Microsoft Azure management portal).

在启用该功能之前,必须将连接字符串配置为要使用的存储帐户。在Microsoft Azure网站中运行Orchard时,可以在部署(在Web.config中)之前或在部署之后(在Microsoft Azure管理门户中)完成。

To configure the connection string before deploying:

要在部署之前配置连接字符串

  1. Open Orchard.sln.

1.打开Orchard.sln

  1. Navigate to Orchard.Web and open the Web.config file.

2.导航到Orchard.Web并打开Web.config文件。

  1. In the <appSettings> element add a setting named Orchard.Azure.Media.StorageConnectionString and set its value to be the connection string of the storage account in which you want to store media content (see example below).

3.在<appSettings>元素中添加名为Orchard.Azure.Media.StorageConnectionString的设置,并将其值设置为要在其中存储媒体内容的存储帐户的连接字符串(请参阅下面的示例)。

  1. Deploy the web site.

4.部署网站。

Here's an example configuration:

这是一个示例配置:

<appSettings>

    ...

    <add key="Orchard.Azure.Media.StorageConnectionString" value="[storageConnectionString]"/>

</appSettings>

The storage connections string will look something like the following:

存储连接字符串将类似于以下内容:

DefaultEndpointsProtocol=http;AccountName=myAccount;AccountKey=myKey;

*You can get the account name and key from the Microsoft Azure management portal

 that you used to create your storage or ask you dev ops admin to provide them for you.

To configure the connection string after deploying:

要在部署后配置连接字符串

  1. Deploy the web site.

1.部署网站。

  1. In the management portal, navigate to your web site and select the Configure tab.

2.在管理门户中,导航到您的网站并选择 Configure 选项卡。

  1. Under App settings add a setting named Orchard.Azure.Media.StorageConnectionString and set its value to be the connection string of the storage account in which you want to store media content.

2.在 App settings 下,添加名为Orchard.Azure.Media.StorageConnectionString的设置,并将其值设置为要在其中存储媒体内容的存储帐户的连接字符串。

  1. Click Save.

4.单击保存

You can now enable the feature Microsoft Azure Media Storage in the admin dashboard.

您现在可以在管理仪表板中启用功能 Microsoft Azure Media Storage

NOTE: For multi-tenancy scenarios the Orchard.Azure.Media.StorageConnectionString setting can optionally be prefixed with a tenant name.

注意:对于多租户方案,“Orchard.Azure.Media.StorageConnectionString”设置可以选择以租户名称为前缀。

Enabling for any other hosting

启用任何其他主机

To enable the feature when running Orchard in any other hosting environment, use the Web.config method described above. Once the connection string has been added to the <appSettings> element, can enable the feature Microsoft Azure Media Storage in the admin dashboard.

要在任何其他托管环境中运行Orchard时启用该功能,请使用上述的“Web.config”方法。将连接字符串添加到<appSettings>元素后,可以在管理仪表板中启用功能 Microsoft Azure Media Storage

Using a custom domain name for blob storage

为blob存储使用自定义域名

Microsoft Azure Blob Storage allows the use of your own custom domain instead of the default endpoint hostname [mystorageaccount].blob.core.windows.net.

Microsoft Azure Blob Storage允许使用您自己的自定义域而不是默认端点主机名[mystorageaccount] .blob.core.windows.net

However, registering and configuring a custom domain in your storage account is not enough to make Orchard use it. Unless you also reconfigure your storage connection string to take advantage of your custom domain, Orchard will continue to generate public URLs for the media files stored in Microsoft Azure Blob Storage based on the default [mystorageaccount].blob.core.windows.net hostname.

但是,在存储帐户中注册和配置自定义域不足以使Orchard使用它。除非您还要重新配置存储连接字符串以利用自定义域,否则Orchard将继续根据默认的`[mystorageaccount] .blob.core.windows.net“为存储在Microsoft Azure Blob存储中的媒体文件生成公共URL。主机名。

To ensure the public URLs for your media files contain your custom domain name, modify your storage account connection string accordingly. See the topic Configuring Connection Strings in the Microsoft Azure Storage documentation for details.

要确保媒体文件的公用URL包含自定义域名,请相应地修改存储帐户连接字符串。有关详细信息,请参阅Microsoft Azure存储文档中的[配置连接字符串]主题(http://msdn.microsoft.com/en-us/library/windowsazure/ee758697.aspx)。

Here's an example connection string using a custom domain name:

以下是使用自定义域名的示例连接字符串:

BlobEndpoint=http://blobs.mycustomdomain.com;AccountName=mystorageaccount;AccountKey=KauG3A5f...An3QlW5dA==

Multi-tenancy configuration

多租户配置

For multi-tenancy scenarios each setting can optionally be prefixed with a tenant name followed by colon, such as SomeTenant:Orchard.Azure.Media.StorageConnectionString. Whenever the media storage provider reads configuration settings it will always first look for a setting specific for the current tenant, and if no such setting exists, fallback to the default non-prefixed setting.

对于多租户方案,每个设置可以选择以租户名称后跟冒号作为前缀,例如SomeTenant:Orchard.Azure.Media.StorageConnectionString。每当媒体存储提供程序读取配置设置时,它将始终首先查找特定于当前租户的设置,如果不存在此类设置,则回退到默认的非前缀设置。

Here's an example Azure Web Site configuration with two tenants, both using Microsoft Azure Blob Storage is the underlying file system implementation for storing media, but each using its own separate storage account:

以下是带有两个租户的Azure Web站点配置示例,两者都使用Microsoft Azure Blob Storage是用于存储媒体的基础文件系统实现,但每个都使用自己独立的存储帐户:

<appSettings>

    <!-- Setting for Tenant1 -->

    <add key="Tenant1:Orchard.Azure.Media.StorageConnectionString" value="[storageConnectionString1]" />

    <!-- Setting for Tenant2 -->

    <add key="Tenant2:Orchard.Azure.Media.StorageConnectionString" value="[storageConnectionString2]" />

</appSettings>