Last active
December 27, 2015 10:39
-
-
Save saintc0d3r/7312652 to your computer and use it in GitHub Desktop.
[Windows Azure] Creating a CloudStorageAccount instance from cloud configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A sample in a ASP NET MVC's controller on how to initialise CloudStorageAccount instance through reading the config | |
public class HomeController : Controller | |
{ | |
static HomeController() { | |
// Get cloud configuration setting & parse it as a CloudStorageAccount instance | |
string cloudStorageConfigSetting = CloudConfigurationManager.GetSetting("DataConnectionString""); | |
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(cloudStorageConfigSetting); | |
// Do something with cloudStorageAccount instance such as prepareing Table, Blob, Queue storage clients | |
} | |
public ActionResult Index(string message = "") { | |
ViewBag.Message = message; | |
return View(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<ServiceConfiguration serviceName="DemoApp" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="3" osVersion="*" schemaVersion="2013-03.2.0"> | |
<Role name="DemoApp_WebRole"> | |
<Instances count="1" /> | |
<ConfigurationSettings> | |
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" /> | |
<!-- The new config setting --> | |
<Setting name="DataConnectionString" value="UseDevelopmentStorage=true" /> | |
</ConfigurationSettings> | |
</Role> | |
</ServiceConfiguration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<ServiceConfiguration serviceName="DemoApp" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="3" osVersion="*" schemaVersion="2013-03.2.0"> | |
<Role name="DemoApp_WebRole"> | |
<Instances count="1" /> | |
<ConfigurationSettings> | |
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" /> | |
<!-- The new config setting --> | |
<Setting name="DataConnectionString" value="UseDevelopmentStorage=true" /> | |
</ConfigurationSettings> | |
</Role> | |
</ServiceConfiguration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<ServiceDefinition name="GuestBookDemo" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2013-03.2.0"> | |
<WebRole name="GuestBook_WebRole" vmsize="Small"> | |
<Sites> | |
<Site name="Web"> | |
<Bindings> | |
<Binding name="Endpoint1" endpointName="Endpoint1" /> | |
</Bindings> | |
</Site> | |
</Sites> | |
<Endpoints> | |
<InputEndpoint name="Endpoint1" protocol="http" port="80" /> | |
</Endpoints> | |
<Imports> | |
<Import moduleName="Diagnostics" /> | |
</Imports> | |
<!-- The new config setting --> | |
<ConfigurationSettings> | |
<Setting name="DataConnectionString" /> | |
</ConfigurationSettings> | |
</WebRole> | |
</ServiceDefinition> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment