Windows Azure portal connection strings - azure

couple of questions regarding the connection strings section for websites in the windows azure portal:
do the settings in the portal take precedence over what's in web.config? If so, should I not include connection strings in the web.config file? Are the settings in the portal sometimes referred to as app.config?
can i set connection strings for ado.net entities in the windows azure portal? This does not seem to work for this specific type of connection string.
in the portal i included the following connection string and gave it the same name as what is in my web.config:
metadata=res:///Models.TABLENAME.csdl|res:///Models.TABLENAME.ssdl|res://*/Models.TABLENAME.msl;provider=System.Data.SqlClient;provider connection string="Server=tcp:SERVERNAME.database.windows.net;Database=DATABASENAME;User ID=USER;Password=PASSWORD;Trusted_Connection=False;Encrypt=True;
The connection string in my web.config file works in my dev environment, but i think i have something typed wrong on the azure portal.

"do the settings in the portal take precedence over what's in web.config?"
Yes.
"If so, should I not include connection strings in the web.config file? "
Use the connectionstring found in Azure portal and insert it in your web.config.
This, of course, does not apply to if you are using a local database. Then you should use the local connectionsstring.
"Are the settings in the portal sometimes referred to as app.config?"
No. Not if you are stil on the subject of connectionstrings.
"can i set connection strings for ado.net entities in the windows azure portal? This does not seem to work for this specific type of connection string"
Check my blog post on basic set up for this here under step 2(2. Now, go to the Management portal and Create a new db.) http://geekswithblogs.net/MagnusKarlsson/archive/2012/10/31/add-sql-azure-database-to-azure-web-role-and-persist.aspx

Related

Access websites connection string from web jobs

I have been trying to move my connection strings from the App.config files for my webjobs to the host website through the Azure Portal. I've tried the likes of:
ConnectionStringSettings test = ConfigurationManager.ConnectionStrings["AzureDB"];
I've also tried using GetSetting and putting the connectionstring in the app section of the configure options as a key/value pair.
That still only shows my local connection strings. I've also tried using the CloudConfigurationManager to no avail.
There are examples all over the place and in SO citing:
However, you don't have to set it in app.config for the web job if you set them in the portal. The WebJobs SDK knows how to read them from there.
So how do I access them?
Install Microsoft Azure Configuration Manager
Move your connection strings to the appSetting section (for debug purpose)
Retrieve you connection string using the CloudConfigurationManager:
var myConnectionString = CloudConfigurationManager.GetSetting("MyConnectionString");
You can now manage your connection string from within the Azure portal.
Azure WebJobs shares the settings with your website
http://blog.ploeh.dk/2014/05/16/configuring-azure-web-jobs/

Why do I need to configure connection strings for WebJobs in Azure Management Portal rather than in the App.config of my WebJob?

I created a scheduled Azure WebJob by right clicking on my WebApp project and adding a New Azure web project. I set the the AzureWebJobsDashboard and AzureWebJobsStorage connection strings in the App.config of the WebJob project. I left the default code in the .cs files alone for now. Next, I published from Visual Studio (2013 Update 4 by the way) to an Azure website. It created the WebJob and I can run it from the Azure Management site or Visual Studio and it is successful. I can see the output logs where I expect them to be. However, the Azure WebJob Details page shows the following warnings/errors:
Make sure that you are setting a connection string named
AzureWebJobsDashboard in your Microsoft Azure Website configuration by
using the following format
DefaultEndpointsProtocol=https;AccountName=NAME;AccountKey=KEY
pointing to the Microsoft Azure Storage account where the Microsoft
Azure WebJobs Runtime logs are stored.
The configuration is not properly set for the Microsoft Azure WebJobs
Dashboard. In your Microsoft Azure Website configuration you must set
a connection string named AzureWebJobsDashboard by using the following
format DefaultEndpointsProtocol=https;AccountName=NAME;AccountKey=KEY
pointing to the Microsoft Azure Storage account where the Microsoft
Azure WebJobs Runtime logs are stored.
It also provides a link that was to http://azure.microsoft.com/blog/2013/07/17/windows-azure-web-sites-how-application-strings-and-connection-strings-work/ which doesn't explain why I am getting the error message.
Now, to get this warning/error to go away, I go add the same AzureWebJobsDashboard connection string in the configure page in the Azure Management site.
So, I'm trying to figure out if I did something wrong or if this is just a kink in the WebJobs that Microsoft hasn't fixed yet. I would really like to be able to have this in the App.config rather than have to remember to set it up in each website we spawn up for different environments.
Thank you very much for your time and help.
The dashboard doesn't have access to your web job's app.config file and even if it did, you might have multiple webjobs so it wouldn't know which connection string to pick. That is why you need to set the connection string in the portal.
However, you don't have to set it in app.config for the web job if you set them in the portal. The WebJobs SDK knows how to read them from there.
I had to manually add authorization headers:
For get the value anfter "Basic " I used this code:
var byteArray = Encoding.ASCII.GetBytes("<user>:<password>");
var base64 = Convert.ToBase64String(byteArray);
Ithink is a Azure Scheduler UI bug

New to Windows Azure Preview

3 questions about Windows Azure Website Preview service (placing my website into cloud):
1. A little embarrassing, but I can't find my FTP credential. I tried my website setup credential as well as the data source string. Both are not applicable. So where is it?
2. I also need database access too, but can't seem to find the entry URL for that as well. Any inputs are appreciated.
3. Finally, I bought my own domain. How can I do an alias (maybe from Apache or IIS, not sure though) so that users only see example.com instead of example.azurewebsites.net?
You'll find the FTP credentials in the publish profile. In the Windows Azure portal, simply open the dashboard of that site and choose Download publish profile. Open that file with any text editor and you'll see the FTP credentials.
If you want to use a database, go to the dashboard of that site and choose to add a linked resource. There you'll be able to add an SQL Database. Once you've done that you'll see the connection string under Quick Glance > View connection strings
Using your own domain with Windows Azure Web Sites is only possible with reserved instances with a CNAME.
If you want to deploy your application to Windows Azure Websites over FTP, you can take a look at my blog here which explains most of the info related to FTP deployment.
As Sandrino explained you can look at View Connections Settings at Quick Glance, also if you look at following sections in the article here you will get more on this regard:
How to: Configure a website to use a SQL database
How to: Configure a website to use a MySQL database
Rest is already answered for you.

What is the item of 'connection strings' for on azure? And how could I add it?

Here is the picture.
http://www.dotup.org/uploda/www.dotup.org3258537.jpg
I have an connection string to connect to the SQL Server Database on the web.config of my website.
Would this item on the azure portal bring benefits to me?
It is the connection string for items in the Linked Resources section of the portal for the website - which currently only supports SQL Database (and not Windows Azure Storage, for example). The following is documented:
Connections Strings – View connection strings for linked resources.
For .NET sites, these connection strings will be injected into your
.NET configuration connectionStrings settings at runtime, overriding
existing entries where the key equals the linked database name. For
PHP and Node sites these settings will be available as environment
variables at runtime.
Note Connection strings are created when you link a database resource
to a website and are read only when viewed on the configuration
management page.

Windows Azure Connection Strings - How to Handle Local vs. Production?

I'm in the process of deploying some windows azure projects and I've noticed that it's a bit of a pain to constantly switch my role configuration settings from using LocalStorage to actually use my Windows Azure Storage connection strings.
For local development, I want to use this:
UseDevelopmentStorage=true
But for deployed apps, I want to use something like:
DefaultEndpointsProtocol=https;AccountName=myAccountName;AccountKey=blah
I end up either changing my role's configuration connection strings just before I deploy, or if I forget to do that, I'll attempt to go into the Windows Azure portal and change them (but that usually happens after I watch my role instances start and stop over and over).
I feel like I'm missing something basic, but is there a straight-forward way to have the deployment process switch my role connection settings to use the production storage accounts instead of local storage?
You can use CloudConfigurationManager in Azure SDK 1.7 http://msdn.microsoft.com/en-us/LIBRARY/microsoft.windowsazure.cloudconfigurationmanager
This starts by looking in the ServiceConfiguration.cscfg e.g. ServiceConfiguration.Cloud.cscfg for config setting. If it isn't there it falls back to web.config and app.config
For example
CloudConfigurationManager.GetSetting("StorageConnectionString")
Will look in the appropriate cscfg file for StorageConnectionString setting, then it will search the web.config and then app.config.
If you want to use Visual Studio config transformations, see my answer to the question Panagiotis mentioned.
Switching from one connectionstring to another when moving from development to cloud
Cheers.
If you use CI server you can change the connection string there automatically. Details here.
I've answered a similar question here:
Visual Studio 2010 can apply Debug or Release transformations to Web.config, but what about the Azure settings?

Resources