Managing Azure Role Configuration

I don’t see how Windows Azure allows you to change the configuration of an application when you have no choice but to save the configuration settings to web.config (or app.config).

For instance...

Quite often, projects will use a third-party library that uses web.config heavily. Using web.config may include connection strings, application settings, or custom configuration sections. A good example of this is ELMAH. The web.config file for ELMAH may look like this:

<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 are several issues here:

  • I have no way to update or change if remote access is allowed between service configurations.

  • I have no way to update or change the ELMAH connection string between service configurations.

, web.config .cspkg, ELMAH ( ).

, ...

  • , .
  • , .

... .

- , Windows Azure?

, , . , . , (, , ). .

, .cspkg, zip . Linux.

.cspkg :

<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", .

: AED69299C5F89E060876BC16BD3D6DE5130F6E62FFD2B752BAF293435339B7E2

: E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855

, , .

, . :

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 ).

- , ?

+5
2

Stream ComputeHash() byte[]. , .

- :

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();
}

, .

, , , linux

openssl dgst -sha256 /path/to/file
+2

web.config, , , , Azure, . Web.config. , , , , (... Local.csfg → Debug,... Cloud.csfg → Release). , , .

, , , .

0

All Articles