Azure Deployment Slot Connection String
Important to note here is the connection string name: Rider will generate a connection string that can be used by our application when running as a web app: The Azure Publish to Web App run configuration can deploy ASP.NET Core web apps (on any platform), and.NET framework web apps (on Windows). Applies the configuration elements of the destination slot to the source slot, including the slot-specific connection strings and app settings. Restarts the worker processes on the source slot using these aforementioned configuration elements. When you complete the swap: Moves the pre-warmed-up source slot into the destination slot. To configure an app setting or connection string to stick to a specific slot (not swapped), go to the Configuration page for that slot. Add or edit a setting, and then select deployment slot setting. Selecting this check box tells App Service that the setting is not swappable.
Azure Web App Deployment Slots are used to deploy new versions of an application code into production with no interruption to the production traffic. In order to achieve this the swap process involves multiple steps that are performed to prepare the new version of the code to successfully handle the load once it is in production slot. Some of these steps may go wrong, especially when the new version of the code does not cooperate well. This in turn either causes the swap to fail or it results in swapping new code in production while it is still not ready to handle the production load. This post describes the most common reasons why this may happen and how to correct them.
In order to better understand the reasons for the swap failures it is first necessary to explain how the application code in the staging slot is initialized / warmed up prior to the swap to production. Failures during these steps are the most common reasons for the overall failure of the swap operation.
The swap operation is done by an internal process that runs within a scale unit where web app is hosted. Here are the steps that it performs to ensure the application is initialized prior to the swap. Note that the same sequence of actions happens during Auto-Swap and Swap with Preview.
- Apply the production configuration settings to all web app’s instances in the staging slot. This happens when web app has appsettings or connection strings marked as “Slot settings” or if Continuous Deployment is enabled for the site or if Site Authentication is enabled. This will trigger all instances in the staging slot to restart. (For Swap with Preview this the first phase of the swap after which the swap process is paused and you can validate that the application works correctly with production settings)
- Wait for every instance to complete its restart. If some instance failed to restart then the swap process will revert any configuration changes to the app in staging slot and will not proceed further. If that happens the first place to look into is the D:homeLogFileseventlog.xml file of the application specific error log (such as php_errors.log for PHP apps) where you may find more clues what prevents application from starting.
- If Local Cache is enabled then swap process will trigger Local Cache initialization by making an HTTP request to the root directory URL path (“/”) of the web app on every web worker. Local Cache Initialization consists of copying the site’s content files from network share to the local disk of the worker and then re-pointing the web app to use local disk for its content. This causes another restart of the web app. The swap process will wait until the Local Cache is completely initialized and restarted on every instance before proceeding further. A common reason why Local Cache Initialization may fail is when site content size exceeds the local disk quota specified for the Local Cache. If that is the case the the quota can be increased by following instructions from Local Cache Documentation.
- If Application Initialization (AppInit) is enabled then swap process will make another HTTP request to the root URL path on every web worker. The AppInit is a module that runs within the web app request processing pipeline and it gets executed when web app starts. The only thing the swap process does with its first HTTP request to the web app is it triggers the AppInit module to do its work. After that it just waits until AppInit reports that it has completed the warmup. AppInit module uses the list of URL paths specified inside web.config file and makes internal HTTP requests to each of those. All these requests are within the web app process. It does not call any external URL’s and its requests are not going through the scale unit’s front ends. Also, neither the initial HTTP request nor AppInit internal requests follow HTTP redirects. That causes the most common problem that users run into with this module. If web app has such rewrite rules as “Enforce Domain” or “Enforce HTTPs” then none of the warmup requests will actually reach the application code. All the requests will be shortcut by the rewrite rules. In order to prevent that the rewrite rules need to be modified like below:
The {WARMUP_REQUEST} is a server variable that is set by AppInit module for each of its internal requests. That is a reliable way to distinguish whether the request is external or is made by AppInit module. The {REMOTE_ADDR} is a server variable that contains the IP address of HTTP client. The IP address ranges starting with “10.” or “100.” are internal to the scale unit and no outside HTTP client can use them.
- If AppInit is not enabled then swap process just makes an HTTP request to the root path of the webapp on each web worker and as long as it receives some HTTP response it considers the warmup complete. Again the rewrite rules in the web app can cause the site to return HTTP redirect response and the actual application code will not be executed at all. Since the AppInit is not involved here the only way to prevent the rewrite rules is to use the {REMOTE_ADDR} server variable in the rule’s conditions as shown below.
- After all the above steps are completed successfully the actual swap is performed by switching the routing rules on the scale unit’s front ends. More details on what happens during the swap can be found in other blog post “How to warm up Azure Web App during deployment slots swap”
Some other common problems that cause the swap to fail:
- An HTTP request to the root URL path times out. The swap process waits for 90 seconds for the request to return. In case of timeout the request will be retried for up to 5 times. If after that the request still times out then the swap operation will be aborted. If that happens then check the eventlog.xml or application specific error log to see if there are any indications of what causes the timeout.
- An HTTP request to the root URL path is aborted. This may happen if web app has a rewrite rule to abort some requests. If that is the case then the rule can be modified by adding the {REMOTE_ADDR} check as shown in previous examples.
- Web App has IP restriction rules that prevent the swap process from connecting to it. In that case you’ll need to allow the internal IP address range used by the swap process:
azure app service configuration connection string
azure function no connection string named could be found in the application config file
azure sql connection string integrated security
arm template entity framework connection string
entity framework azure ad authentication
azure connection string best practices
azure connection string in web config
We have an ASP .NET (MVC) app and are using Entity Framework 6 to connect to our databases. The DbContext is constructed in a standard way and it loads the connection string on our behalf. The generated code looks like this:
We set the connection string in a local web.config also in a standard way:
When we publish the app to Azure we navigate to the Azure Portal, then to the Web App's Settings, then to the list of Connection Strings. There we add the EF connection string that we had used locally. When we restart and visit the app we get a run-time error depending on the type of connection string we choose.
For a Custom
type we get the following run-time error:
Keyword not supported: 'data source'.
For SQL Server
or SQL Database
we get the following run-time error:
Keyword not supported: 'metadata'.
This really seems like a straightforward story so we are wondering what is going wrong.
The problem is the escaped quotes: "
.
The connection strings in web.config have quotes escaped because they are serialized in an XML attribute. When entering a connection string in the Azure portal you should provide the raw unescaped string. Something like this:
metadata=...;provider connection string='Data Source=...'
David Ebbo's answer is good for confirming that the Environment is set up as you expect. It is also helpful to pay attention to the .pubxml file when publishing via the wizard in Visual Studio: it will try to populate connection strings as well.
Setting EF Connection String in Azure Web App, In Azure Web App application settings, there are 4 values required for connecting string: Name; Value; Provider Type; Slot Setting (Optional). Update connection string for entity framework in Azure Web App settings Mohit Goyal Microsoft Azure July 5, 2017 January 22, 2019 2 Minutes One of the coolest things about Windows Azure Websites is the integration with source control, and the automated deployment hooks Azure offers.
'custom' should be correct here. In that case, the providerName is left unchanged, so if you have System.Data.EntityClient
in your config, that should remain after the Azure runtime changes it.
Try going to Kudu Console and click on Environment to make sure the conn string looks correct there.
Update connection string for entity framework in Azure Web App , In the Azure Management / Web Apps / [Your web app] / CONFIGURE / connection strings , make sure of 3 things : 1.The connection string has An application running on the desktop or on a device can store the connection string in an app.config or web.config file. Add the connection string to the AppSettings section in these files. An application running in an Azure cloud service can store the connection string in the Azure service configuration schema (.cscfg) file. Add the connection string to the ConfigurationSettings section of the service configuration file.
Azure Deployment Slot Connection Strings
If you have this line in web.connfig
Add this in azure portal:
Make sure (as stated in first answer) to replace "
with '
How best to make Azure database connection string be an EF , NET developer that is intentional. “App settings” neatly map to the .NET Framework's appSettings configuration. Similarly “connection strings” Since the key-value pairs for both “app settings” and “connection strings” are stored in environment variables, developers can easily retrieve these values from any of the web application frameworks supported in Windows Azure Web Sites.
Windows Azure Web Sites: How Application Strings and Connection , This topic covers how Entity Framework discovers which database If you have not done any other configuration in your application, then calling the Use Code First with connection string in app.config/web.config file. And the only string I store together within the actual app service/ func/ web job, would be the connection string for accessing the Azure App Configuration. In my Startup where the configuration settings is applied I either read from ..settings.json, and if not present (which it should not be if running on Azure), I look for the connection
Azure Deployment Slot Connection String Function
Connection strings and models, NET Core app working in Azure App Service, with connection to a SQL Database. ef migrations add InitialCreate # Set connection string to production To configure the deployment user, run the az webapp deployment Configure connection strings. In the Azure portal, search for and select App Services, and then select your app. In the app's left menu, select Configuration > Application settings.
Tutorial: ASP.NET Core with SQL Database, All Site Content Microsoft's Entity Framework is an object-relational mapper that enables . Add a LocalDb connection string to your App.config in the project using the database In the Add Connection dialog, use the following settings:. Configure application settings for Azure Static Web Apps Preview. 05/08/2020; 4 minutes to read; In this article. Application settings hold configuration settings for values that may change, such as database connection strings. Adding application settings allows you to modify the configuration input to your app, without having to change
How To Configure Connection String and App Settings for Azure , On the Settings stage of the Publish dialog: Expand Databases and check Use this connection string at runtime; Expand Entity Framework Migrations and check The providerName setting is not required on EF Core connection strings stored in App.config because the database provider is configured via code. You can then read the connection string using the ConfigurationManager API in your context's OnConfiguring method.
Comments
- Take a look here: azure.microsoft.com/blog/2013/07/17/…
- I have the same problem and after spending a long time searching I haven't figured out the solution. Azure just ignores Application Settings and use the connection string from web.config. As I see in the Channel 9 video, it would be 'magic', but doesn't is.
- Please pay attention that the web.config connectionstrings are needed anyway in your azure web app. Only the connectionString part will be replaced by the Azure Web App runtime reading from your enviroment.