Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to store configuration values in Azure Service fabric application

I am working on Azure Service Fabric Reliable Actor implementation. Any idea/link on where can I store the Configuration value (e.g. DB connection string) and how to access that in code.

like image 942
Pratik Mehta Avatar asked Jan 26 '16 10:01

Pratik Mehta


People also ask

What is Applicationmanifest XML?

Every app project must have an AndroidManifest. xml file (with precisely that name) at the root of the project source set. The manifest file describes essential information about your app to the Android build tools, the Android operating system, and Google Play.

How many nodes can be maintained on a service Fabric cluster?

A single Service Fabric node type/scale set can not contain more than 100 nodes/VMs. To scale a cluster beyond 100 nodes, add additional node types.

Is Azure service Fabric deprecated?

Today, we are announcing the retirement of Azure Service Fabric Mesh. We will continue to support existing deployments until April 28th, 2021, however new deployments will no longer be permitted through the Service Fabric Mesh API.

What is node in Azure service Fabric?

In this article A Service Fabric cluster is a network-connected set of virtual or physical machines into which your microservices are deployed and managed. A machine or VM that's part of a cluster is called a node.


2 Answers

A Service Fabric application consists of the code package, a config package, and the data (https://azure.microsoft.com/en-gb/documentation/articles/service-fabric-application-model/).

You can use the config package to store and retrieve any kind of key-value pairs you need e.g. a connection string. Have a look at this article https://azure.microsoft.com/en-us/documentation/articles/service-fabric-manage-multiple-environment-app-configuration/ for more information.

like image 173
charisk Avatar answered Sep 28 '22 07:09

charisk


You can add multiple ApplicationParameters file. Just copy and paste the same from Cloud.Xml and use for multiple environment configurations.

Steps to Make necessary changes

  1. The values given in the Settings.xml need to be overridden in the ApplicationManifest.xml when it imports the ServiceManifest.xml .Below is the code supporting the overriding changes add them in the ApplicationManifest.xml.

    a) Add the Parameter Default value first

      <Parameters>
         <Parameter Name="StatelessService1_InstanceCount" DefaultValue="-1" />
         <!-- Default Value is set to Point to Dev Database  -->
         <Parameter Name="DatabaseString"DefaultValue="Server=someserver.database.windows.net\;Database=DbDev;user id=[userid];password=[Password];Trusted_Connection=false;" />
      </Parameters>
    

    b) Then override it in the ServiceManifestImport

      <ServiceManifestImport>
              <ServiceManifestRef ServiceManifestName="StatelessServicePkg" 
                      ServiceManifestVersion="1.0.0" />          
          <ConfigOverrides>
               <ConfigOverride Name="Config">
                    <Settings>
                         <Section Name="DatabaseConnections">
                                 <Parameter Name="DbString" Value="[DatabaseString]" />
                        </Section>
                   </Settings>
             </ConfigOverride>
        </ConfigOverrides>
      </ServiceManifestImport>
    
  2. The above code change will override the following code in settings.xml

    <Section Name="DatabaseConnections">
        <Parameter Name="DbString" Value="Server=someserver.database.windows.net\;Database=DbDev;user id=[userid];password=[Password];Trusted_Connection=false;" />
    </Section> 
    
  3. Overall when the application is deployed the values in the ApplicationParameter DevParam.xml or QaParam.xml or ProdParam.xml will overtake all the setting values.

     <Parameters>
         <Parameter Name="StatelessService1_InstanceCount" Value="-1" />
              <Parameter Name="DatabaseString" Value="Server=someserverqa.database.windows.net\;Database=DbQA;user id=[userid];password=[Password];Trusted_Connection=false;" />
     </Parameters>
    
like image 45
user3530857 Avatar answered Sep 28 '22 07:09

user3530857