Backingup Azure WebApp when connection string is injected through keyvault - azure

I am using Azure Keyvault to store my connection string of a database. Using connection string options in configuration of Azure WebApps, I inject the connection string as #Microsoft.KeyVault(SecretUri=https://vaultlink....) without any problems I can access the connection string on the application side.
However, if i try to use WebApps Backup function while connection string is set #Microsoft.KeyVault..., backup fails saying that Database connection string not valid for database secretfnlafter (SQLAzure). Keyword not supported: '#microsoft.keyvault(secreturi'.
What is the correct way of backingup azure webapp when using kayvault for connection string

I can reproduce your issue, seems the backup does not support the connection string references the keyvault.
You could post it as an idea in the azure feedback:https://feedback.azure.com/forums/34192--general-feedback

Related

Where is Azure storage account connection string in Azure portal?

I try to upload a XML file to Azure FTP server, using this code:
https://www.c-sharpcorner.com/article/upload-and-download-files-from-blob-storage-using-c-sharp/
I have difficulty to how find storageAccount_connectionString? I have access to the server in Azure portal but I cannot find this connection string.
//Copy the storage account connection string from Azure portal
storageAccount_connectionString = "your Azure storage account connection string here";
The connection Strings are found from Storage Account Access Keys Blade as already said by Gaurav Mantri (StorageAccount>>AccessKeys>>ShowKeys).
If you are using a Primary Access Key then you can use the connection string in Box 1 and if you are using Secondary Access Key then you can use the connection string in Box 2.
You can refer the below Microsoft Documents for more information:
View and Manage Keys
Configure Connection Strings

Check validity of Azure Storage connection string before launching application

I have a web application where "Azure Storage connection string" is passed as an environment variable in docker-compose file.
The problem is that Azure Storage is only related with a few features of the app, and if invalid connection string was passed, we won't noticed it until relevant functions failed in production.
I have tried entrypoint.sh for the app container. It seems to be a great place to check environment variables. But I cannot find a solution to validate "Azure Storage connection string" in this script.
Is it possible to validate "Azure Storage connection string" before making the app up & running?

Azure Key Valut connection to Azure SQL

I have successfully setup a Linked Service in Azure Data Factory that uses a Key Vault for the connection string which includes the user/pwd and connects to the Azure SQL DB as desired. However, I can only do this when I use the "admin" account. The string below works.
Server=tcp:database1.database.windows.net,1433;Initial Catalog=DB;Persist Security Info=False;User ID=Admin;Password=Pa$$w0rd;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
I created a new login/user and granted the necessary permissions. I know because I can connect using the new login via remote SSMS or by adding the credentials directly in the linked service in Azure. (e.g. hard coding the user/pwd in the connection string in the linked service)
Unfortunately, when I switch to using the key vault connection string, I get the generic SQLErrorNumber 18456 for the newly created user. I know the credentials are correct, I know I can connect via the Key Vault (when using the elevated admin account), I just cannot use the Key Vault connection string when using the new user.
Server=tcp:database1.database.windows.net,1433;Initial Catalog=DB;Persist Security Info=False;User ID=Username;Password=Pa$$w0rd;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
If using Azure SQL with Data Factory look at using Managed Service Identity That way you'd add the name of the Data Factory directly to the SQL DB and no need for a username and password. Plus can assign permissions directly on the user.
Only downside is if DataFactory get's wiped out and redeployed the user will need to be dropped and recreated since it is using a thumbprint to recognize the Identity, this isn't the case with all resources and MSI auth.
For your specific case check to make sure the SQL server is allowing Azure Services and resource to Access the sever by going to "Firewalls and virtual networks" and make sure it is turned on:

Azure - WebJobs - Use remote connection string

I have WebJobs running under my Azure Web App. For Web App you can set that the Web App will use remote connection strings (that you setup on Azure portal).
Is it possible to do the same for WebJobs?
So they would be looking for remote connection string instead of using a connections string from (for example) "app.config".
Could you add the connection string as Web Config value that can be accessed by either the site or webjob?
Further more details you could refer to this blog:Configuring Azure Web Jobs.
The main steps are as follows:
Install CloudConfigurationManager package Microsoft.WindowsAzure.ConfigurationManager
Set your connection strings to the app setting.
Retrieve connection string using the CloudConfigurationManager:
var myConnectionString = CloudConfigurationManager.GetSetting("MyConnectionString");
I found out that a connection string setup on Azure Portal overwrites connection string with the same name in .config files. Which means that no additional setup is required.
Azure Portal Connection string takes priority over local *.config connection string.
I successfully tested this.

how to override local connection string with azure connection string

I am using appsettings.json in .Net core project for connection string. My connection string is :
"ConnectionStrings": {
"OT_DB_Connection": "Data Source=108.***.**.**;Initial Catalog=O*******s;User ID=O*******s;Password=O*********$"
},
In startup.cs i am accessing connection string with key like this
options.UseSqlServer(Configuration.GetConnectionString("OT_DB_Connection"));
I deployed this code on azure and i have sql database on azure.
After deployment how my website will use the connection string of azure ?
How to override the local connection string with azure connection string at run time.
You should read the following article:
Multiple Environment Configuration Files in ASP.NET Core
You can have multiple appSettings e.g. 1 for you local environment and 1 for Azure etc. When you publish your app to Azure, you can add an application setting called ASPNETCORE_ENVIRONMENT and add a value that maps to your environment for your app to pick up the correct configuration. If you have an appSettings.Azure.json file you can set ASPNETCORE_ENVIRONMENT to Azure and it will use that configuration file.
If you do not want to take this approach, you can also override the connection string directly in Azure as show in the picture below. This is accessible under your app service -> Application Settings -> Connection Strings. You will want to override OT_DB_Connection.

Resources