Skip to content

Commit 8c6cc57

Browse files
authored
Merge pull request #234206 from v-ksreedevan/12Apr-SQLpermissions
SQL permissions
2 parents f6fc3ba + 8a33fbf commit 8c6cc57

11 files changed

+580
-77
lines changed

articles/migrate/add-server-credentials.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: vikram1988
55
ms.author: vibansa
66
ms.manager: abhemraj
77
ms.topic: how-to
8-
ms.date: 11/13/2022
8+
ms.date: 04/13/2023
99
ms.custom: engagement-fy23
1010
---
1111

@@ -43,7 +43,7 @@ The table below lists the permissions required on the server credentials provide
4343
Feature | Windows credentials | Linux credentials
4444
---| ---| ---
4545
**Software inventory** | Guest user account | Regular/normal user account (non-sudo access permissions)
46-
**Discovery of SQL Server instances and databases** | User account that is member of the sysadmin server role. | _Not supported currently_
46+
**Discovery of SQL Server instances and databases** | User account that is a member of the sysadmin server role or has [these permissions](migrate-support-matrix-vmware.md#configure-the-custom-login-for-sql-server-discovery) for each SQL Server instance.| _Not supported currently_
4747
**Discovery of ASP.NET web apps** | Domain or non-domain (local) account with administrative permissions | _Not supported currently_
4848
**Agentless dependency analysis** | Domain or non-domain (local) account with administrative permissions | Sudo user account with permissions to execute ls and netstat commands. If you are providing a sudo user account, ensure that you have enabled **NOPASSWD** for the account to run the required commands without prompting for a password every time the sudo command is invoked. <br /><br /> Alternatively, you can create a user account that has the CAP_DAC_READ_SEARCH and CAP_SYS_PTRACE permissions on /bin/netstat and /bin/ls files, set using the following commands:<br /><code>sudo setcap CAP_DAC_READ_SEARCH,CAP_SYS_PTRACE=ep /bin/ls<br /> sudo setcap CAP_DAC_READ_SEARCH,CAP_SYS_PTRACE=ep /bin/netstat</code>
4949

@@ -65,4 +65,4 @@ Feature | Windows credentials | Linux credentials
6565

6666
## Next steps
6767

68-
Review the tutorials for discovery of servers running in your [VMware environment](tutorial-discover-vmware.md) or [Hyper-V environment](tutorial-discover-hyper-v.md) or for [discovery of physical servers](tutorial-discover-physical.md)
68+
Review the tutorials for discovery of servers running in your [VMware environment](tutorial-discover-vmware.md) or [Hyper-V environment](tutorial-discover-hyper-v.md) or for [discovery of physical servers](tutorial-discover-physical.md).

articles/migrate/how-to-discover-sql-existing-project.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: vineetvikram
55
ms.author: vivikram
66
ms.manager: abhemraj
77
ms.topic: how-to
8-
ms.date: 08/19/2022
8+
ms.date: 04/13/2023
99
ms.custom: engagement-fy23
1010
---
1111

@@ -22,14 +22,14 @@ This discovery process is agentless that is, nothing is installed on the target
2222
- Created an [Azure Migrate project](./create-manage-projects.md) before the announcement of SQL and web apps assessment feature for your region
2323
- Added the [Azure Migrate: Discovery and assessment](./how-to-assess.md) tool to a project
2424
- Review [app-discovery support and requirements](./migrate-support-matrix-vmware.md#vmware-requirements).
25-
- In case you're discovering assets on VMware environment then, Make sure servers where you're running app-discovery have PowerShell version 2.0 or later installed, and VMware Tools (later than 10.2.0) is installed.
25+
- In case you're discovering assets on a VMware environment, make sure the servers where you're running app discovery have PowerShell version 2.0 or later installed, and VMware tools (later than 10.2.0) installed.
2626
- Check the [requirements](./migrate-appliance.md) for deploying the Azure Migrate appliance.
2727
- Verify that you have the [required roles](./create-manage-projects.md#verify-permissions) in the subscription to create resources.
2828
- Ensure that your appliance has access to the internet
2929

3030
> [!Note]
31-
> Even though the processes in this document are covered for VMware, the processes are similar for Microsoft Hyper-V and Physical environment.
32-
> Discovery and assessment for SQL Server instances and databases is available across the Microsoft Hyper-V and Physical environment also.
31+
> Though the procedure described in this article is for VMware, the processes are similar for Microsoft Hyper-V and Physical environments.
32+
> Discovery and assessment for SQL Server instances and databases is available across the Microsoft Hyper-V and Physical environments.
3333
3434
## Enable discovery of web apps and SQL Server instances and databases
3535

@@ -44,7 +44,7 @@ This discovery process is agentless that is, nothing is installed on the target
4444
- Validate that the services running on the appliance are updated to the latest versions. To do so, launch the Appliance configuration manager from your appliance server and select view appliance services from the Setup prerequisites panel.
4545
- Appliance and its components are automatically updated
4646
:::image type="content" source="./media/how-to-discover-sql-existing-project/appliance-services-version.png" alt-text="Check the appliance version":::
47-
- In the manage credentials and discovery sources panel of the Appliance configuration manager, add Domain or SQL Server Authentication credentials that have Sysadmin access on the SQL Server instance and databases to be discovered.
47+
- In the manage credentials and discovery sources panel of the Appliance configuration manager, add Domain or SQL Server Authentication credentials that have Sysadmin access on the SQL Server instance and databases to be discovered or have [these permissions](migrate-support-matrix-vmware.md#configure-the-custom-login-for-sql-server-discovery) for each SQL Server instance.
4848
- Web apps discovery works with both domain and non-domain Windows OS credentials as long as the account used has local admin privileges on servers.
4949
You can leverage the automatic credential-mapping feature of the appliance, as highlighted [here](./tutorial-discover-vmware.md#start-continuous-discovery).
5050

@@ -59,7 +59,7 @@ This discovery process is agentless that is, nothing is installed on the target
5959
6060
## Next steps
6161

62-
- Learn how to create an [Azure SQL assessment](./how-to-create-azure-sql-assessment.md)
63-
- Learn more about [Azure SQL assessments](./concepts-azure-sql-assessment-calculation.md)
64-
- Learn how to create an [Azure App Service assessment](./how-to-create-azure-app-service-assessment.md)
65-
- Learn more about [Azure App Service assessments](./concepts-azure-webapps-assessment-calculation.md)
62+
- Learn how to create an [Azure SQL assessment](./how-to-create-azure-sql-assessment.md).
63+
- Learn more about [Azure SQL assessments](./concepts-azure-sql-assessment-calculation.md).
64+
- Learn how to create an [Azure App Service assessment](./how-to-create-azure-app-service-assessment.md).
65+
- Learn more about [Azure App Service assessments](./concepts-azure-webapps-assessment-calculation.md).

articles/migrate/migrate-support-matrix-hyper-v.md

Lines changed: 132 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: Vikram1988
55
ms.author: vibansa
66
ms.manager: abhemraj
77
ms.topic: conceptual
8-
ms.date: 03/08/2023
8+
ms.date: 04/13/2023
99
ms.cutom: engagement-fy23
1010
---
1111

@@ -86,7 +86,7 @@ Support | Details
8686
**Windows servers** | Windows Server 2008 and later are supported.
8787
**Linux servers** | Currently not supported.
8888
**Authentication mechanism** | Both Windows and SQL Server authentication are supported. You can provide credentials of both authentication types in the appliance configuration manager.
89-
**SQL Server access** | Azure Migrate requires a Windows user account that is a member of the sysadmin server role.
89+
**SQL Server access** | To discover SQL Server instances and databases, the Windows or SQL Server account must be a member of the sysadmin server role or have [these permissions](#configure-the-custom-login-for-sql-server-discovery) for each SQL Server instance.
9090
**SQL Server versions** | SQL Server 2008 and later are supported.
9191
**SQL Server editions** | Enterprise, Standard, Developer, and Express editions are supported.
9292
**Supported SQL configuration** | Discovery of standalone, highly available, and disaster protected SQL deployments is supported. Discovery of HADR SQL deployments powered by Always On Failover Cluster Instances and Always On Availability Groups is also supported.
@@ -97,6 +97,136 @@ Support | Details
9797
>
9898
> However, you can modify the connection settings, by selecting **Edit SQL Server connection properties** on the appliance.[Learn more](/sql/database-engine/configure-windows/enable-encrypted-connections-to-the-database-engine) to understand what to choose.
9999
100+
### Configure the custom login for SQL Server discovery
101+
102+
The following are sample scripts for creating a login and provisioning it with the necessary permissions.
103+
104+
#### Windows Authentication
105+
106+
```sql
107+
-- Create a login to run the assessment
108+
use master;
109+
-- If a SID needs to be specified, add here
110+
DECLARE @SID NVARCHAR(MAX) = N'';
111+
CREATE LOGIN [MYDOMAIN\MYACCOUNT] FROM WINDOWS;
112+
SELECT @SID = N'0x'+CONVERT(NVARCHAR, sid, 2) FROM sys.syslogins where name = 'MYDOMAIN\MYACCOUNT'
113+
IF (ISNULL(@SID,'') != '')
114+
PRINT N'Created login [MYDOMAIN\MYACCOUNT] with SID = ' + @SID
115+
ELSE
116+
PRINT N'Login creation failed'
117+
GO
118+
119+
-- Create user in every database other than tempdb and model and provide minimal read-only permissions.
120+
use master;
121+
EXECUTE sp_MSforeachdb 'USE [?]; IF (''?'' NOT IN (''tempdb'',''model'')) BEGIN TRY CREATE USER [MYDOMAIN\MYACCOUNT] FOR LOGIN [MYDOMAIN\MYACCOUNT] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH'
122+
EXECUTE sp_MSforeachdb 'USE [?]; IF (''?'' NOT IN (''tempdb'',''model'')) BEGIN TRY GRANT SELECT ON sys.sql_expression_dependencies TO [MYDOMAIN\MYACCOUNT] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH'
123+
EXECUTE sp_MSforeachdb 'USE [?]; IF (''?'' NOT IN (''tempdb'',''model'')) BEGIN TRY GRANT VIEW DATABASE STATE TO [MYDOMAIN\MYACCOUNT] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH'
124+
GO
125+
126+
-- Provide server level read-only permissions
127+
use master;
128+
BEGIN TRY GRANT SELECT ON sys.sql_expression_dependencies TO [MYDOMAIN\MYACCOUNT] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
129+
BEGIN TRY GRANT EXECUTE ON OBJECT::sys.xp_regenumkeys TO [MYDOMAIN\MYACCOUNT] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
130+
BEGIN TRY GRANT VIEW DATABASE STATE TO [MYDOMAIN\MYACCOUNT] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
131+
BEGIN TRY GRANT VIEW SERVER STATE TO [MYDOMAIN\MYACCOUNT] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
132+
BEGIN TRY GRANT VIEW ANY DEFINITION TO [MYDOMAIN\MYACCOUNT] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
133+
GO
134+
135+
-- Required from SQL 2014 onwards for database connectivity.
136+
use master;
137+
BEGIN TRY GRANT CONNECT ANY DATABASE TO [MYDOMAIN\MYACCOUNT] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
138+
GO
139+
140+
-- Provide msdb specific permissions
141+
use msdb;
142+
BEGIN TRY GRANT EXECUTE ON [msdb].[dbo].[agent_datetime] TO [MYDOMAIN\MYACCOUNT] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
143+
BEGIN TRY GRANT SELECT ON [msdb].[dbo].[sysjobsteps] TO [MYDOMAIN\MYACCOUNT] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
144+
BEGIN TRY GRANT SELECT ON [msdb].[dbo].[syssubsystems] TO [MYDOMAIN\MYACCOUNT] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
145+
BEGIN TRY GRANT SELECT ON [msdb].[dbo].[sysjobhistory] TO [MYDOMAIN\MYACCOUNT] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
146+
BEGIN TRY GRANT SELECT ON [msdb].[dbo].[syscategories] TO [MYDOMAIN\MYACCOUNT] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
147+
BEGIN TRY GRANT SELECT ON [msdb].[dbo].[sysjobs] TO [MYDOMAIN\MYACCOUNT] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
148+
BEGIN TRY GRANT SELECT ON [msdb].[dbo].[sysmaintplan_plans] TO [MYDOMAIN\MYACCOUNT] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
149+
BEGIN TRY GRANT SELECT ON [msdb].[dbo].[syscollector_collection_sets] TO [MYDOMAIN\MYACCOUNT] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
150+
BEGIN TRY GRANT SELECT ON [msdb].[dbo].[sysmail_profile] TO [MYDOMAIN\MYACCOUNT] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
151+
BEGIN TRY GRANT SELECT ON [msdb].[dbo].[sysmail_profileaccount] TO [MYDOMAIN\MYACCOUNT] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
152+
BEGIN TRY GRANT SELECT ON [msdb].[dbo].[sysmail_account] TO [MYDOMAIN\MYACCOUNT] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
153+
GO
154+
155+
-- Clean up
156+
--use master;
157+
-- EXECUTE sp_MSforeachdb 'USE [?]; BEGIN TRY DROP USER [MYDOMAIN\MYACCOUNT] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;'
158+
-- BEGIN TRY DROP LOGIN [MYDOMAIN\MYACCOUNT] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
159+
--GO
160+
```
161+
162+
#### SQL Server Authentication
163+
164+
```sql
165+
-- Create a login to run the assessment
166+
use master;
167+
-- If a SID needs to be specified, add here
168+
DECLARE @SID NVARCHAR(MAX) = N'';
169+
IF (@SID = N'')
170+
BEGIN
171+
CREATE LOGIN [evaluator]
172+
WITH PASSWORD = '<provide a strong password>'
173+
END
174+
ELSE
175+
BEGIN
176+
CREATE LOGIN [evaluator]
177+
WITH PASSWORD = '<provide a strong password>'
178+
, SID = @SID
179+
END
180+
SELECT @SID = N'0x'+CONVERT(NVARCHAR, sid, 2) FROM sys.syslogins where name = 'evaluator'
181+
IF (ISNULL(@SID,'') != '')
182+
PRINT N'Created login [evaluator] with SID = '+@SID
183+
ELSE
184+
PRINT N'Login creation failed'
185+
GO
186+
187+
-- Create user in every database other than tempdb and model and provide minimal read-only permissions.
188+
use master;
189+
EXECUTE sp_MSforeachdb 'USE [?]; IF (''?'' NOT IN (''tempdb'',''model'')) BEGIN TRY CREATE USER [evaluator] FOR LOGIN [evaluator]END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH'
190+
EXECUTE sp_MSforeachdb 'USE [?]; IF (''?'' NOT IN (''tempdb'',''model'')) BEGIN TRY GRANT SELECT ON sys.sql_expression_dependencies TO [evaluator]END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH'
191+
EXECUTE sp_MSforeachdb 'USE [?]; IF (''?'' NOT IN (''tempdb'',''model'')) BEGIN TRY GRANT VIEW DATABASE STATE TO [evaluator]END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH'
192+
GO
193+
194+
-- Provide server level read-only permissions
195+
use master;
196+
BEGIN TRY GRANT SELECT ON sys.sql_expression_dependencies TO [evaluator] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
197+
BEGIN TRY GRANT EXECUTE ON OBJECT::sys.xp_regenumkeys TO [evaluator] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
198+
BEGIN TRY GRANT VIEW DATABASE STATE TO [evaluator] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
199+
BEGIN TRY GRANT VIEW SERVER STATE TO [evaluator] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
200+
BEGIN TRY GRANT VIEW ANY DEFINITION TO [evaluator] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
201+
GO
202+
203+
-- Required from SQL 2014 onwards for database connectivity.
204+
use master;
205+
BEGIN TRY GRANT CONNECT ANY DATABASE TO [evaluator] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
206+
GO
207+
208+
-- Provide msdb specific permissions
209+
use msdb;
210+
BEGIN TRY GRANT EXECUTE ON [msdb].[dbo].[agent_datetime] TO [evaluator] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
211+
BEGIN TRY GRANT SELECT ON [msdb].[dbo].[sysjobsteps] TO [evaluator] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
212+
BEGIN TRY GRANT SELECT ON [msdb].[dbo].[syssubsystems] TO [evaluator] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
213+
BEGIN TRY GRANT SELECT ON [msdb].[dbo].[sysjobhistory] TO [evaluator] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
214+
BEGIN TRY GRANT SELECT ON [msdb].[dbo].[syscategories] TO [evaluator] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
215+
BEGIN TRY GRANT SELECT ON [msdb].[dbo].[sysjobs] TO [evaluator] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
216+
BEGIN TRY GRANT SELECT ON [msdb].[dbo].[sysmaintplan_plans] TO [evaluator] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
217+
BEGIN TRY GRANT SELECT ON [msdb].[dbo].[syscollector_collection_sets] TO [evaluator] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
218+
BEGIN TRY GRANT SELECT ON [msdb].[dbo].[sysmail_profile] TO [evaluator] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
219+
BEGIN TRY GRANT SELECT ON [msdb].[dbo].[sysmail_profileaccount] TO [evaluator] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
220+
BEGIN TRY GRANT SELECT ON [msdb].[dbo].[sysmail_account] TO [evaluator] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
221+
GO
222+
223+
-- Clean up
224+
--use master;
225+
-- EXECUTE sp_MSforeachdb 'USE [?]; BEGIN TRY DROP USER [evaluator] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;'
226+
-- BEGIN TRY DROP LOGIN [evaluator] END TRY BEGIN CATCH PRINT ERROR_MESSAGE() END CATCH;
227+
--GO
228+
```
229+
100230
## Web apps discovery requirements
101231

102232
[Software inventory](how-to-discover-applications.md) identifies web server role existing on discovered servers. If a server is found to have a web server installed, Azure Migrate discovers web apps on the server.

0 commit comments

Comments
 (0)