Archived Support Site

This support site is archived. You can view the old support discussions but you cannot post new discussions.

Could a Connection String change (if Nothing Else is Changed)?

atolken's Avatar

atolken

28 Nov, 2016 09:13 PM

I remember reading somewhere to not copy-and-paste the connection string from the add-on since there is a chance that it could change.

Instead use the alias, and rely on after-build injecting the connection string -- which works fine for me.

I've been searching for this, but have not been able to find it, and am thinking that I may have misunderstood it the first time I read it.

Can the connection change if the application is not updated, and if so under what conditions?

  1. Support Staff 1 Posted by rune on 29 Nov, 2016 06:35 AM

    rune's Avatar

    Hi,

    The scenarios where add-on configuration is updated depends on the add-on, but I'm assuming you're referring to the SQL Server/MySQL database add-ons? If so the most common updates occur when you access the add-on admin pages and for instance reset the password, enable MARS (in the case of SQL server) or setting the connection string alias.

    The configuration may also be updated at times when maintenance-related tasks requires it. That being said these updates occur much less frequently as we're able to handle most of those tasks without updating the add-on's configuration (e.g. by updating the server IPs with the CNAME associated with the database URL).

    Note that the configuration of add-ons isn't dependent on whether the application itself is updated, but updating the add-on configuration always triggers a redeployment of the running application. Otherwise it sounds like you've got the right understanding of how this works :-)

    Let me know if there's anything else I can help with!

    Best,
    Rune

  2. 2 Posted by atolken on 29 Nov, 2016 08:30 PM

    atolken's Avatar

    Thanks for explaining.

    In other words to get the most stable result, it sounds like:

    - Connection String Alias with AppHarbor injection (after deploy) is 99.9999% reliable
    - Pasting the connection string into a Web.release.config transform is 99.9998% reliable

    I mean when considering all possibilities and wishing to complete a project without needing to be concerned that something is going to go down.

    Am I understanding correctly?

  3. Support Staff 3 Posted by rune on 29 Nov, 2016 10:43 PM

    rune's Avatar

    Hi,

    I wouldn't frame it that way actually -- the recommended way is to use either the connection string alias, or using the connection string in the configuration variable also injected in your application's AppSettings (e.g. SQLSERVER_CONNECTION_STRING). That'd allow the most stable result, but as long as you're aware of and willing to maintain any configuration you hardcode in a configuration file you're of course welcome to do that :-)

    Perhaps I'll be able to provide better advice if you provide more information about your use case - in particular, why do you want/need to put the connection string in the Web.Release.config?

    Best,
    Rune

  4. 4 Posted by atolken on 29 Nov, 2016 10:58 PM

    atolken's Avatar

    Hi

    I like the idea of simplifying deployment as much as possible. Basically getting as close to "one-click" as possible.

    Right now it's pretty close -- plus I've documented the extra steps needed in the readme.md -- but I feel that it could be slightly better if one did not have to set up a Connection String Alias.

    I've come to really like Web.config transforms, since it means that the next person who wishes to make a change to that project doesn't need to anything except publish (even if they're publishing a new copy / for the first time).

    Overall, I am satisfied with the service (and you may considered this discussion as resolved).

    Thanks for your responses -- they were useful.

  5. Support Staff 5 Posted by rune on 29 Nov, 2016 11:15 PM

    rune's Avatar

    Hi,

    Ok great - just have one more comment that may help to achieve what I think you want. It sounds like you're preparing an application that other people needs to be able to set up with minimal configuration (e.g. setting up the alias after provisioning a database). That's possible, you'd just have to initialize the Sql connection in your code instead of relying on the alias. How to initialize the client depends on the which one you use but one simple solution would look like this:

    var sqlConnection = new SqlConnection(ConfigurationManager.AppSettings["SQLSERVER_CONNECTION_STRING"])
    

    This way you avoid relying on the alias at all and the users would just need to provision the database add-on.

    Best,
    Rune

  6. rune closed this discussion on 29 Nov, 2016 11:15 PM.

  7. atolken re-opened this discussion on 30 Nov, 2016 12:23 AM

  8. 6 Posted by atolken on 30 Nov, 2016 12:23 AM

    atolken's Avatar

    Hi,

    Thanks for sharing. I suspected that would work. However I wanted to leave Entity Framework to do it's default thing.

    I'll keep in it mind.

  9. atolken closed this discussion on 30 Nov, 2016 12:23 AM.

Discussions are closed to public comments.
If you need help with AppHarbor please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac