Trying to create User of External UserType against a SqlManagedInstance results in error
还没有人认领这个 Issue。
评估
调研方向
先从 UserBase.cs 中围绕 UserType 验证的已引用代码行开始,然后检查 SqlSmoObject.cs 和 LocalizableResources.strings 中的引擎名称逻辑。在 SQL Managed Instance 上复现 External 用户创建,并验证验证逻辑接受该版本,且生成的错误能正确识别 Azure SQL Managed Instance。
由索引模型根据 Issue 内容生成。
描述
Hi @shueybubbles, greetings from the dbatools team 😄
I'm trying to add a SqlUser of type [Microsoft.SqlServer.Management.Smo.UserType]::External on a newly created SQL MI.
DatabaseEngineEdition: SqlManagedInstance
ServerVersion.Major: 16
SMO Version: 16
File version: 16.200.46367.54
I'm getting the following exception:
Exception : System.Management.Automation.MethodInvocationException: Exception calling "Create" with "0" argument(s): "Create failed for
User 'claudio@********.onmicrosoft.com'. "
---> Microsoft.SqlServer.Management.Smo.FailedOperationException: Create failed for User
'claudio@********.onmicrosoft.com'.
---> Microsoft.SqlServer.Management.Smo.UnsupportedVersionException: 'User'.'UserType': 'External' is not a valid option for SQL Server 2017.
Code to reproduce:
$smoUser = New-Object Microsoft.SqlServer.Management.Smo.User
$smoUser.Parent = $dbSMO
$smoUser.Name = "claudio@********.onmicrosoft.com"
$smoUser.Login = "claudio@********.onmicrosoft.com"
$smoUser.UserType = [Microsoft.SqlServer.Management.Smo.UserType]::External
$smoUser.DefaultSchema = "dbo"
$smoUser.Create()
Note: with T-SQL it works.
From my analysis the problem is here (assuming the comment): https://github.com/microsoft/sqlmanagementobjects/blob/98093604e9ede97aa2a9b066279f0bd9d9557c4f/src/Microsoft/SqlServer/Management/Smo/UserBase.cs#L362-L364
It should be 12 <= this.ServerVersion.Major instead of >
Error message
Also, the error message says SQL Server 2017 when it should say SQL Server Managed Instance
It seems it's entering here:
https://github.com/microsoft/sqlmanagementobjects/blob/04249a2dc85ad1aa0d492b8a2cecf65583ded177/src/Microsoft/SqlServer/Management/Smo/SqlSmoObject.cs#L6919
I would suggest adding a new validation similar with
https://github.com/microsoft/sqlmanagementobjects/blob/04249a2dc85ad1aa0d492b8a2cecf65583ded177/src/Microsoft/SqlServer/Management/Smo/SqlSmoObject.cs#L6898-L6901
But like:
if (sp.TargetDatabaseEngineType == DatabaseEngineType.SqlAzureDatabase)
{
return LocalizableResources.EngineCloud;
}
else if (sp.TargetDatabaseEngineType == DatabaseEngineType.Standalone && sp.DatabaseEngineEdition == DatabaseEngineEdition.SqlManagedInstance)
{
return LocalizableResources.EngineCloudMI;
}
And add here:
https://github.com/microsoft/sqlmanagementobjects/blob/73cd2cb929409cb9ddc2c7b416c5d7c6ef621d5f/src/Microsoft/SqlServer/Management/Smo/LocalizableResources.strings#L26
A new entry
EngineCloudMI = Microsoft Azure SQL Managed Instance
PS: I'm more than happy to submit a PR with these changes if it's ok for you.
Thanks!
- 主要语言
- C#
- 星标
- 143
- 派生
- 28
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/sqlmanagementobjects 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
-
难度 3/5 1-2 天 新手友好度 72/100
-
难度 4/5 3-5 天 新手友好度 74/100
-
难度 3/5 1-2 天 新手友好度 78/100
-
难度 3/5 1-2 天 新手友好度 68/100
查看 microsoft/sqlmanagementobjects 的全部 Issue
相似的 Issue
-
:watch: Not Triaged dotnet-fsharp/svc
难度 1/5 1 小时以内 新手友好度 90/100
-
Client customer-reported needs-team-attention question Service Attention WebPubSub
难度 2/5 1-3 小时 新手友好度 76/100
Azure/azure-sdk-for-net#63292 · 3 条评论 · 1 个 reaction ·
-
Issue-Enhancement Needs-Triage
难度 1/5 1 小时以内 新手友好度 86/100
PowerShell/PowerShell#28061 · 2 个 reaction ·
-
dependencies needs-team-triage server-Azure.Mcp
难度 2/5 1-3 小时 新手友好度 72/100
-
aspnet-core/svc aspnetcore-signalr/subsvc doc-enhancement Pri2 SignalR
难度 1/5 1 小时以内 新手友好度 88/100
dotnet/AspNetCore.Docs#37729 ·