-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d4792f
commit d392597
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
docs/_drafts/2024-04-05-powershell-function-for-setting-azure-sql-permissions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
layout: post | ||
title: Set specific database role permissions Azure SQL | ||
categories: powershell azure sql rbac | ||
--- | ||
|
||
## Introduction | ||
|
||
I had to set permissions on multiple databases on an Azure SQL server. | ||
I decided to create a function for this that can set specific database role permissions on all or one SQL database within an Azure SQL server. | ||
|
||
![Azure SQL](../assets/images/post_2024-04_azureSql.png){:width="50%"} | ||
|
||
The script uses sqlcmd to connect to the Azure SQL server and configure the permissions. So apart from PowerShell, you will need to have the Az.Accounts PowerShell module and the SqlServer PowerShell module installed. | ||
Or you can automate it even further by using an Azure DevOps pipeline or GitHub action that first installs PowerShell and the required modules. | ||
|
||
Of course you need to either connect using the Sql administrator account or the Microsoft Entra admin for Azure Sql. (The Entra admin can also be a security group in Entra Id) | ||
|
||
SqlCmd is very picky about quotes, especially if your Entra ID group has spaces, so the script does some replacing of single quotes (') with two single quotes (''). | ||
|
||
## The script | ||
|
||
Without further ado, here's the script: | ||
|
||
{% gist MarcoJanse/f78534f8d22a9b215a476a122ac5e6aa %} | ||
|
||
## Closing notes | ||
|
||
I hope someone will make good use of this script or make it even better. | ||
|
||
## References | ||
|
||
- [Authorize database access to SQL Database, SQL Managed Instance, and Azure Synapse Analytics \| Microsoft Learn](https://learn.microsoft.com/en-us/azure/azure-sql/database/logins-create-manage?view=azuresql) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.