We have a windows service that provisions Azure SQL databases for our clients. We are using Microsoft.WindowsAzure.Management.Sql API. I have a database named "Green" in a Server located in 'East Asia', Server Version 'v12'. Today we found that my database data are not found. My tables, stored procedures and data are missing.
Restoring deleted Azure SQL Database Using the Azure Portal
To restore a database in the Azure Portal do the following:
Open the Azure Portal.
On the left side of the screen select BROWSE > SQL servers.
Navigate to the server with the deleted database you want to restore and select the server
Scroll down to the operations section of your server blade and select Deleted databases: Restore an Azure SQL database
Select the deleted database you want to restore
Specify a database name, and click Ok:
Related
I have created an ASP.NET Core MVC application and published it directly via VS 2022 to Azure. It includes EF and Identity.
What is the best approach to also connect the database with data?
I have connected the database, but that didn't work as expected. All the data is missing
You can deploy your local database to Azure and connect with Web application.
I deploy My local database which is having SQL server authentication by following below procedure:
I selected the database and right click on it I go to below option:
Clicked on Deploy Database to Microsoft Azure SQL Database.
Connected to the Azure database server By clicking on connect option.
Image for reference:
It connected successfully.
Image for reference:
Summary of operation:
I click on finish. The operation started and completed successfully.
Image for reference:
My database is deployed to azure SQL database successfully.
Image for reference:
In this way we can deploy Local database to Azure SQL database.
Connecting to application:
Create web application go to publish page of that
From the View menu, select SQL Server Object Explorer.
At the top of SQL Server Object Explorer, click the Add SQL Server button.
In connect dialog box expand your azure node and connect to the database with username and password
Add client IP
database connected successfully.
In this way you can connect with azure SQL database.
Through SSMS, connecting to my on prem server, you can right click a database, select tasks and "DEPLOY DATABASE TO MICROSOFT AZURE SQL DATABASE". Is there a way to log/audit who did this from my on prem server?
After doing this, I've checked the SQL Server logs and do not see any entries for this.
Thanks!
You should be able to investigate the logs using power-BI content pack refer below link.
https://powerbi.microsoft.com/fr-be/blog/monitor-azure-audit-logs-with-power-bi/
You can also use Azure Activity Log API to check the resource changes refer API link below for details - https://learn.microsoft.com/en-us/rest/api/monitor/activity-logs/list?tabs=HTTP
In the past, when using SQL Server login, this could be accomplished by below steps:
Run GRANT VIEW SERVER STATE TO /*server_login */ in the master database
Then run select * from sys.dm_exec_sessions as "server_login".
It would get all the connections, including all connections to my target database.
Now migrating to a "contained user" for a "contained database", I tried this:
Run GRANT VIEW DATABASE STATE TO /*contained_user */ in my target database
Then run select * from sys.dm_exec_sessions as "contained user"
It would only see myself, not other active connections to this target database.
The database in SQL Server 2019. What options do I have to allow a contained user to view all active connections to this database?
For SQL server, the permission VIEW SERVER STATE is still needed.
Azure Database is different. I set up Azure Database today to verify that VIEW DATABASE STATE is sufficient.
I read this article: https://msdn.microsoft.com/en-us/library/azure/ee336235.aspx
I don't know how to connect to the master database. I don't see it anywhere on the portals.
I want to be able to manage which credentials have access to which db and at which level. Preferably using a GUI.
There are a couple of ways to manage credentials in Azure SQL DB.
The simplest is to use the GUI in the NEW azure portal (https://portal.azure.com/) -- open the SQL Database server of interest and manage access using the "Roles" and "Users" options in the "Access" group at the bottom of your Server pane.
You can also connect to the Server using Visual Studio (SQL Server Data Tools add-in). Open Visual Studio and under VIEW, select SQL Server Object Explorer. You can add the Azure DB server to that tree, you will have an option of connecting to the "Master" database (under System Databases) and running SQL commands to create users, or graphically add new users under Master > Security > Users. Once the user is created, logins can be created and then individual database permissions added.
I have a SQL Server 2008, which is part of a domain. Now I make a backup of a database of this server and restore it on a SQL Server, which is not part of a domain.
I have an C# application, which uses this database. On the NON-Domain machine I get now exceptions like this:
"Cannot execute as the database prinzipal because the principial "dbo" does not exist, this type of principal cannot be impersonatedm or you don not have the permission"
I think, the problem is, that the database owner is a domain user and this user doesn't exist on the target machine (backup machine)!? How can I solve this ?
The MS SQL server follows a 2 layer user system.
You must make sure that your login is an actual login on the SQL Server (this refers to the SQL Server itself NOT to the actual database).
You find the SQL Server users in the Management Studio under:
Server root -> Security - Logins
After you ensured that your login is available you have to map it to a user/schema. In Order todo so you must:
Select the SQL Server user you want to map
Right click on the user
Select properties
Switch to the User Mapping tab
Choose the database you want to create a mapping for
Select the Database user you want to associate the currently selected SQL Server user with
Done