I want to make staging database the same as production on Azure - sql

My production and staging databases are on Azure and I want to make staging the same as production. I have no idea what to do, I have never worked with databases. I use SQL Server 2014.

There are a few ways to do this, but the quickest way would probably be to replace your staging database when you want the updated data by Creating a new database as a copy. Now, this would wipe out any changes to your staging database, but would be the fastest way.
More complicated, but probably a bit more about what you're actually thinking of, would be setting up azure data sync from Prod -> Staging.

Staging Azure web app has different configuration with production Azure web app. We can configure the same connection string at Azure portal to achieve this requirement. Refer to this article for more information about how to configure connection string in Azure portal. At runtime, Azure Web App will automatically retrieves values in Azure portal and makes them available to code running in your website. If the same connection string configured in Azure portal, the staging and production will use the same database.

Related

Dev Environment creation from Prod for Azure SQL

I have a production server in Azure SQL. I have created a another empty server(dev) for development purpose. I need a copy of the tables, views, stored procedure in the dev server as well. Please suggest some way to transfer the data to dev server database
#John11 : You can take a backup of your Production Database and then simply restore on your Dev server
Ideally Production data restore to Dev is not advisable if it is a highly confidential data
If you just need to move the schema without data then you can use DevOps / CI-CD to deploy the artifacts to Dev

Copy Data From On-Premise SQL Server To Azure SQL - Azure Private Network

Requirement: I wanted to copy data from a specific table/view residing on a on-premise SQL Server to Azure SQL DB.
Infrastructure: As depicted in below picture. Essentially, the Azure network is directly connected with corporate network over Express Route. Thus it's a pure private network connection; as good as the corporate network itself.
Issue/Question: I know there are multiple approaches present to get this operation done and I am not restricted to use ADF copy Data tool only. BUT, for all of these I see some cavets or extra steps needed to be done as below:
ADF Copy Data Tool: Needs a SH-IR and a small MSI package needs to be installed on on-premise machine which hosts the SQL server for registration purpose.
Logic Apps: Needs a Virtual Gateway (OR) ASE
App Service: If the operation is wrapped in a C# application and I choose to deploy to a Azure Web Apps. Then in-order to connect to on-premise SQL Server we need to setup hybrid connection manager and as in #1 we need to install something in on-premise machine.
For my case, none of these extra steps can be done. essentially, the on-premise SQL Server comes under a different BU and thus I don't have any permission there; except they have given grant to a table/view. Thus, none of these extra shitty steps can be done.
Moreover, as mentioned above; since it's connected over express route as direct connection, As can be seen in above picture, both the on-premise and azure SQL are essentially inside the same corporate network. THUS, I should be able to access them directly without configuring any of these extra steps as mentioned above.
Please confirm on these and provide a suggestion.
Thank You.
You can still go with the ADF scenario without a SHIR by creating ADF in a Managed VNET using Private Endpoint. As you already have an ER circuit and have the flexibility to configure the Azure side, can you do this with Azure IR: Access on-premises SQL Server from Data Factory Managed VNet using Private Endpoint - Azure Data Factory | Microsoft Docs
There are 2 solutions which could work for your scenario but even for them to work ,you would need access to on prem SQL server machine access to some extent atleast for one time config and Azure SQL db should be accessible via SSMS installed on on-prem machine.
Using linked server
You can create a linked server ( process explained here https://www.sqlshack.com/create-linked-server-azure-sql-database/ ) on on-prem server and create a agent server job to insert data to azure SQL db table.
Via Python Script
This would need Python installation on on-prem machine. Once installed you can write script to transfer data between on-prem SQL server and Azure SQL db. You can schedule this script again by using an agent server job.

Azure App Services cannot connect to Azure SQL Database

I have an API published to Azure App Services, using ef core, connect to Azure SQL database. below are the steps and the problem:
The Azure SQL database is up and running OK, I setup two firewall rules, one for my local dev ip, one for Azure App. I can connect to Azure SQL from local without any issue, and I have done the migrations.
I copied the connection string from Azure SQL and put in the appsettings.json, running the API from my local and connect to Azure SQL without any issue.
I published my API to Azure App services without any issues, I can see my app running OK since it has static file.
Then I went to Azure App Services => Settings/Configuration => Connection strings, create one new connect string with the same key/value as I used in the appsettings.json, based on the document from Microsoft: https://learn.microsoft.com/en-us/azure/app-service/containers/configure-language-dotnetcore#access-environment-variables
But the problem is after I done these, my API still not working, the api call to SQL return error 500.
Anything I missed or did wrong?
Thanks!
Thanks for the comments CSharpRocks, I did by adding the client ip, but I figured that's not the right way, so resolved by set the "Allow Azure services and resources to access this server" to True, that works.
For Others looking for the answer I had followed the steps above and it still did not work for me. But when I went to Visual Studios --> Publish --> Service Dependency's --> Add Azure SQL Database That fixed it for me.

Azure SQL PaaS - Limitations

We are trying to evaluate possibility of migrating our in-house SQL DB server to Azure SQL as a PaaS.
Our legacy windows application which is written in VB6 and now running on VB.NET Framework 4.5
Clarifications I need if I migrate only DB server to Azure:
We use both trusted / credential based SQL connection from our desktop application to connect to SQL DB. If we migrate to Azure SQL, will it support trusted connection which should authenticate current organizations NT user?
We have lot of cross DB queries, do we need to face any challenge to use the queries as it is?
Run time we take a DB backup / restore for some business cases. Does this work?
Are there any restrictions on number of admin users on Azure DB?
Probably yes if you sync your local AD with an AAD (See: Use Azure Active Directory Authentication for authentication with SQL Database, Managed Instance, or SQL Data Warehouse)
Azure SQL Database (PaaS) doesn't support cross DB queries by default - you have to setup / use Elastic Query for that.
Yes, you can take a DB backup at runtime and also restore it. There is also a point-in-time restore feature available. See: Learn about automatic SQL Database backups.
I think you can only specify one server administrator (at least within the portal) but I doubt you will reach any limit on db users.
Instead of using the single database SQL Server PaaS service you should also consider using Managed Instance (preview)
You will have to extend your active directory to Azure active directory to keep using trusted connections. You will learn how to do it on this documentation and this one.
On Azure SQL Database you have elastic queries that allow you to run cross database queries. Learn how to create elastic queries here.
You can create bacpacs (export your databases) to Azure Storage or to on-premises location very easy.
You can configure one Server Admin or one Azure Active Directory Admin (it can be a group) for your Azure SQL Server. However, at the database level you can add many database users to the dbmanager role. You can have more information about this topic here.

deploy Rshiny application connected to an sql database

Please how can i deploy my shiny application developed with R studio and connected an sql database. I created the mysql database on a local server (wampserver) and the application connects to it perfectly but i have to deploy it with the database.
Consider deploying your sql database in the same place that you will be deploying your application. Otherwise, you will need to look into options for exposing your database in such a way that your app will be able to access it.
For example, you could deploy both the database and app on an AWS EC2 instance. Alternatively, you could deploy the database to an RDS instance and connect to it remotely with your app on EC2. Those examples are only pertinent to Amazon resources, but the logic applies regardless of your platform.