Azure角色的配置管理 [英] Azure role configuration management

查看:162
本文介绍了Azure角色的配置管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白的Windows Azure是如何让你改变程序的配置时,你有没有选择,只能在web.config中保存配置设置(或app.config)中。

I don't see how Windows Azure lets you vary the configuration of an application when you have no choice but to hold configuration settings in web.config (or app.config).

例如...

相当经常项目将利用第三方库,使大量使用的web.config的。使用web.config文件可能涉及的连接字符串,应用程序设置或自定义配置节。这方面的一个很好的例子是ELMAH。对于ELMAH web.config文件可能如下所示:

Quite often projects will make use of a 3rd party library that makes heavy use of web.config. The use of web.config may involve connection strings, app settings or custom configuration sections. A good example of this is ELMAH. A web.config file for ELMAH might look like the following:

<configuration>

  <configSections>
    <sectionGroup name="elmah">
      <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
      <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
    </sectionGroup>
  </configSections>

  <connectionStrings>
    <add
      name="MyElmahDatabase"
      providerName="System.Data.SqlClient"
      connectionString="Server=tcp:myServer.database.windows.net,1433;Database=myDB;User ID=user@myServer;Password=password;Trusted_Connection=False;Encrypt=True;Connection Timeout=30" />
  </connectionStrings>

  <elmah>
    <security allowRemoteAccess="1" />
    <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="MyElmahDatabase" />
  </elmah>

</configuration>

有几个问题在这里:


  • 有没有办法,我更新或更改远程访问无论是服务配置之间启用。

  • There is no way for me to update or vary whether remote access is enabled between Service Configurations.

有没有办法,我更新或更改服务配置之间的ELMAH连接字符串。

There is no way for me to update or vary the ELMAH connection string between Service Configurations.

这是因为在web.config被打包为是进入.cspkg文件ELMAH不会在服务配置设置看(这是我可以改变服务配置之间的配置设置的唯一方法)。

This is because the web.config is packaged as is into the .cspkg file and ELMAH will not look at the Service Configuration settings (which are the only way I can vary configuration settings between Service Configurations).

我能想到的许多其他例子,这是一个问题...

I can think of many other examples where this is a problem...


  • 任何直接的连接字符串部分,看起来数据访问框架。

  • 任何自定义配置设置我需要创建。

...命名只有两个。

...to name just two.

我缺少的东西,或这是由Windows Azure的?

Am I missing something or is this a significant gap in the configuration management offered by Windows Azure?

从答案,下面的评论,它看起来像这样的东西是不能很好地支持。我认为,管理多个解决方案,构建配置,以支持不同的配置配置文件是一个非常薄弱的​​解决方案。我不应该重建每个配置文件我需要的解决方案(有可能会相当多)。编译不等于配置。

From the answer and comments below, it looks like this is something that is not well supported. I think that managing multiple solution build configurations to support different configuration profiles is a very weak solution. I should not have to rebuild the solution for each configuration profile I need (there will likely be quite a few). Compilation is not equal to configuration.

我在想,如果有修改.cspkg文件,因为它仅仅是一个zip文件的方式。据这个文档,你可以在Linux上。

I was wondering if there was a way to modify the .cspkg file as it is just a zip file. According to this documentation you can on Linux.

我在.cspkg文件看了看清单和它看起来像这样:

I've looked at the manifest in the .cspkg file and it looks like this:

<PackageManifest version="2">
  <Encryption keytype="1" />
  <Contents hashtype="1">
    <Item name="MyApp.Web.UI_<GUID>.cssx" hash="AED69299C5F89E060876BC16BD3D6DE5130F6E62FFD2B752BAF293435339B7E2" uri="/MyApp.Web.UI_<GUID>.cssx" />
    <Item name="MyApp.Web.Services_<GUID>.cssx" hash="7AC81AFF642E4345173C8470C32A41118A4E3CFD4185B82D0ADA44B71057192D" uri="/MyApp.Web.Services_<GUID>.cssx" />
    <Item name="SMPackage_<GUID>.csmx" hash="B5E6B83B62AF64C7C11CAC1A394ABBF15D7DB7667A773C5284CE5BE95C5834E9" uri="/SMPackage_<GUID>.csmx" />
    <Item name="SDPackage_<GUID>.csdx" hash="F34B7C02A551D82BAD96881E2DA9447D0014D49B47CCB3840475BDC575234A7D" uri="/SDPackage_<GUID>.csdx" />
    <Item name="NamedStreamPackage_<GUID>.csnsx" hash="FA2B5829FF5D9B2D69DCDDB0E5BDEE6B8B0BC09FFBF37DAEEE41CF3F3F4D0132" uri="/NamedStreamPackage_<GUID>.csnsx" />
  </Contents>
  <NamedStreams>
    <Stream name="RequiredFeatures/MyApp.Web.Services/1.0" />
    <Stream name="RequiredFeatures/MyApp.Web.UI/1.0" />
    <Stream name="SupportData/MyApp.Web.Services/1.0" />
    <Stream name="SupportData/MyApp.Web.UI/1.0" />
  </NamedStreams>
</PackageManifest>

不幸的是,如果我重新计算不变MyApp.Web.UI_.cssx文件的哈希值,我散列是一个在不同的清单。

Unfortunately, if I re-compute the hash of the unchanged "MyApp.Web.UI_.cssx" file, my hash is different from the one in the manifest.

从清单哈希:AED69299C5F89E060876BC16BD3D6DE5130F6E62FFD2B752BAF293435339B7E2

Hash from manifest: AED69299C5F89E060876BC16BD3D6DE5130F6E62FFD2B752BAF293435339B7E2

我的计算哈希值:E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855

My calculated hash: E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855

请注意,我还没有更改的文件,所以哈希应该是相同的。

Note that I have not yet changed the file, so the hash should be the same.

这表明我的计算是错误的。我的方法如下:

This suggests I'm calculating it wrong. My method was as follows:

class Program
{
    static void Main(string[] args)
    {
        using (FileStream fs = new FileStream(args[0], FileMode.Open))
        {
            ComputeHash(new SHA256Managed(), fs);
        }
    }

    private static void ComputeHash(HashAlgorithm hashAlgorithm, Stream stream)
    {
        byte[] hash = hashAlgorithm.ComputeHash(stream);
        string hashString = BitConverter.ToString(hash);
        Console.WriteLine(hashString.Replace("-", string.Empty));
        Console.WriteLine();
    }
}

上面的文档链接,表明它是简单的(反正在Linux上)重新计算哈希值。

The documentation link above, suggests it is straightforward to re-calculate the hash (on Linux anyway).

有谁知道如何重新计算哈希?

Does anyone know how to re-compute the hashes?

推荐答案

传递一个 ComputeHash()相比使用字节[] 超负荷用不同的哈希结束。我不知道为什么。

Passing a Stream to ComputeHash() ends up with a different hash as compared to using the byte[] overload. I don't know why.

尝试是这样的:

private static void ComputeHash(HashAlgorithm hashAlgorithm, Stream stream)
{
    BinaryReader reader = new BinaryReader(stream)
    byte[] hash = hashAlgorithm.ComputeHash( reader.ReadBytes( (int)stream.length ) );
    string hashString = BitConverter.ToString(hash);
    Console.WriteLine(hashString.Replace("-", string.Empty));
    Console.WriteLine();
}

这会给你你所追求的哈希值。

This will give you the hash you're after.

正如你可能已经发现了,在Linux上你可以用

As you've probably already discovered, on linux you can get the digest with

openssl dgst -sha256 /path/to/file

这篇关于Azure角色的配置管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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