azure云数据库_保护Azure SQL数据库免于意外删除

azure云数据库

In this article, we will review options called LOCKS in Azure SQL database and Azure SQL Server that are used to protect databases or servers from accidental deletes or configuration changes.

在本文中,我们将介绍Azure SQL数据库和Azure SQL Server中称为LOCKS的选项,这些选项用于保护数据库或服务器免遭意外删除或配置更改。

Azure provides a feature called locking that allows us to lock the resource group or the subscription or the resources and prevent from accidental deletes or configuration changes.

Azure提供了一种称为锁定的功能,该功能使我们可以锁定资源组或订阅或资源,并防止意外删除或配置更改。

Azure provides two types of locks one is the Delete lock that prevents resources, subscriptions and resource groups being deleted. Another one is Read-only that prevents users from updating the resource, resource group, and the subscription.

Azure提供了两种类型的锁,一种是“ 删除”锁,可以防止删除资源,订阅和资源组。 另一个是只读的 ,可以防止用户更新资源,资源组和订阅。

使用Azure门户在Azure SQL数据库上创建LOCKS。 (Creating LOCKS on an Azure SQL database using the Azure portal.)

Log in to the Azure portal and navigate to SQL databases. Click on the database.

登录到Azure门户并导航到SQL数据库。 点击数据库。

Azure SQL databases

In the database details page, Click on Locks under the Settings section.

在数据库详细信息页面中,单击“ 设置”部分下的 锁定

locks on Azure SQL databases

Click on the Add button to add a new lock.

单击添加按钮以添加新锁。

Enter the name of the Lock. In this case, I want to protect the database from accidental deletes. So, I selected the Lock type as Delete. Enter the notes or you can leave it blank and click on OK.

输入锁的名称。 在这种情况下,我想保护数据库免遭意外删除。 因此,我选择了Lock类型作为Delete 。 输入注释,也可以将其保留为空白,然后单击“ 确定”。

delete lock on Azure SQL databases

Now let us try deleting the database. Navigate to the SQL database page. Select the database on which you created the Delete lock and click on the Delete button.

现在让我们尝试删除数据库。 导航到“ SQL数据库”页面。 选择在其上创建了删除锁的数据库,然后单击删除按钮。

delete lock on Azure SQL databases

Type Yes in the confirmation text box and click on the Delete. It throws an error saying the database cannot be deleted due to Delete lock placed on the database.

在确认文本框中键入yes,然后单击删除 。 它引发错误,表明由于数据库上的“ 删除”锁而无法删除数据库。

delete lock on Azure SQL databases

Let us try updating the database configuration when we have an active Delete lock on the database.

当数据库上有活动的Delete锁时,让我们尝试更新数据库配置。

Navigate to the SQL databases. Click on the database and click on Configure under the settings section.

导航到SQL数据库。 单击数据库并根据设置部分点击配置

delete lock on Azure SQL databases

For demo purpose, I am just changing the Data max size from 500 MB to 100 MB. Click on Apply.

出于演示目的,我只是将数据最大大小从500 MB更改为100 MB。 单击“ 应用”

change the configuration of Azure SQL database

Updating the configuration of the database is successful. Please refer to the below image.

数据库配置更新成功。 请参考下图。

change the configuration of Azure SQL database

When we place a Delete lock on the database, we can read and update the database but cannot delete the database.

当我们在数据库上放置删除锁时,我们可以读取和更新数据库,但不能删除数据库。

Let us check how the Read-only lock behaves on the database. I deleted the Delete lock that is created above. To create a read-only lock, follow the above steps and select the lock type as Read-only.

让我们检查一下只读锁在数据库上的行为。 我删除了上面创建的删除锁。 要创建只读锁,请按照上述步骤操作,然后将锁类型选择为只读

Now we have only “Read-only” lock on the Azure SQL database.

现在,我们在Azure SQL数据库上只有“只读”锁。

Deleting the Azure SQL database with read-only lock: I tried deleting the Azure SQL database that has only one lock i.e. Read-only. The delete operation failed with an error as shown in the below image.

删除具有只读锁的Azure SQL数据库:我尝试删除仅具有一个锁(即只读)的Azure SQL数据库。 删除操作失败,并显示错误,如下图所示。

read-only lock on Azure SQL databases

Let us try updating the configuration of the database when the database has a ‘Read-only’ lock. I am scaling the database from Basic 100 MB storage to Basic 50 MB storage. The scaling operation failed with an error as shown in the below image.

当数据库具有“只读”锁时,让我们尝试更新数据库的配置。 我正在将数据库从Basic 100 MB存储扩展到Basic 50 MB存储。 缩放操作失败,并显示错误,如下图所示。

read-only lock on Azure SQL databases

When we have Read-only lock on the database we cannot modify or delete the Azure SQL database.

当我们在数据库上拥有只读锁时,我们将无法修改或删除Azure SQL数据库。

使用Azure门户在Azure SQL Server上创建锁 (Creating LOCKS on an Azure SQL Server using the Azure portal)

We can also create locks at Azure SQL server level. To create locks on the Azure SQL server, navigate to the All Resources page and click on the Azure SQL server.

我们还可以在Azure SQL服务器级别创建锁。 若要在Azure SQL服务器上创建锁,请导航到“ 所有资源”页面,然后单击Azure SQL服务器。

locks on Azure SQL Server

Creating locks on the Azure SQL server is like creating locks in the Azure SQL database. Please follow the above steps.

在Azure SQL服务器上创建锁就像在Azure SQL数据库中创建锁。 请按照上述步骤。

When we create lock at the server level, the databases on the server inherits the locks and the rule applies on all the database on the server. Please refer to the below image for locks that are inherited from the server.

当我们在服务器级别创建锁时,服务器上的数据库将继承锁,并且该规则将应用于服务器上的所有数据库。 请参阅下图,了解从服务器继承的锁。

inherited locks

We can not modify or delete the parent locks from child resources. i.e. the locks that are created on the Azure SQL server cannot be modified or deleted from the Locks page at the Azure SQL database.

我们无法从子资源中修改或删除父锁。 也就是说,不能在Azure SQL数据库的“锁定”页面上修改或删除在Azure SQL服务器上创建的锁定。

In this case, the Read-only lock is placed at the Azure SQL Server level that will not allow us to modify or delete the Azure SQL server and all the databases on the server.

在这种情况下,只读锁位于Azure SQL Server级别,不允许我们修改或删除Azure SQL服务器以及该服务器上的所有数据库。

Locks placed at parent resources are inherited to newly created child resources. For example, if we place a delete lock on the Azure SQL server and if add a new Azure SQL database on the same server, the newly created database will also inherit the delete lock.

放置在父资源上的锁将继承到新创建的子资源。 例如,如果我们在Azure SQL服务器上放置删除锁,并且在同一服务器上添加新的Azure SQL数据库,则新创建的数据库也将继承删除锁。

管理资源组中的锁 (Managing the locks from the Resource group)

To view all the locks placed on child resources in a resource group. Navigate to the Resource groups page. Click on the Resource group name

查看放置在资源组中子资源上的所有锁。 导航到“ 资源组”页面。 单击资源组名称

managing locks from resource group

Click on Locks under the Settings section. You can view the locks on all the resources in that specific resource group. Please refer to the below image. We can see the lock created on the Azure SQL Server and the lock created on Azure SQL database.

单击设置部分下的锁定 。 您可以查看该特定资源组中所有资源的锁定。 请参考下图。 我们可以看到在Azure SQL Server上创建的锁和在Azure SQL数据库上创建的锁。

managing locks from resource group

We cannot add locks on the child resources from the Resource group page. But, we can delete the locks on child resources.

我们无法通过“资源”组页面在子资源上添加锁。 但是,我们可以删除对子资源的锁定。

结论 (Conclusion)

In this article, we explored how to configure locks on the Azure SQL database and the Azure SQL Server with different examples to protect databases from accidental deletion on Azure. In case you have any questions, please feel free to ask in the comment section below.

在本文中,我们通过不同的示例探讨了如何在Azure SQL数据库和Azure SQL Server上配置锁,以保护数据库免于在Azure上意外删除。 如果您有任何疑问,请随时在下面的评论部分中提问。

Please refer to the SQL Azure category to learn more about Azure SQL.

请参考SQL Azure类别以了解有关Azure SQL的更多信息。

翻译自: https://www.sqlshack.com/protecting-azure-sql-databases-from-accidental-deletion/

azure云数据库

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值