%3CLINGO-SUB%20id%3D%22lingo-sub-1491121%22%20slang%3D%22en-US%22%3ESupport%20for%20Azure%26nbsp%3BAD%26nbsp%3Buser%20creation%26nbsp%3Bon%20behalf%20of%20Azure%20AD%20Applications%20for%26nbsp%3BAzure%20SQL%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1491121%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20are%20announcing%20a%20public%20preview%20for%20%3CSPAN%3EAzure%26nbsp%3BAD%26nbsp%3Buser%20creation%26nbsp%3Bsupport%20for%26nbsp%3BAzure%26nbsp%3BSQL%26nbsp%3BDatabase%26nbsp%3Band%20Azure%20Synapse%20Analytics%20on%20behalf%20of%20Azure%20AD%26nbsp%3BApplications%20(service%20principals).%20See%20%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-sql%2Fdatabase%2Fauthentication-aad-service-principal%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Active%20Directory%20service%20principal%20with%20Azure%20SQL%3C%2FA%3E.%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1175841171%22%20id%3D%22toc-hId-1175841171%22%20id%3D%22toc-hId-1175841171%22%20id%3D%22toc-hId-1175841171%22%20id%3D%22toc-hId-1175841171%22%20id%3D%22toc-hId-1175841171%22%20id%3D%22toc-hId-1175841171%22%3E%3CBR%20%2F%3EWhat%20support%20for%20Azure%20AD%20user%20creation%20on%20behalf%20of%20Azure%20AD%20Applications%20means%3F%3C%2FH3%3E%0A%3CP%3E%3CSPAN%3EAzure%20SQL%26nbsp%3BDatabase%2C%20Azure%20Synapse%20Analytics%20(%3C%2FSPAN%3E%3CSPAN%3Ef%3C%2FSPAN%3Eormerly%20SQL%20Data%20Warehouse%3CSPAN%3E)%2C%20and%20SQL%20Managed%20Instance%20support%20the%20following%20Azure%26nbsp%3BAD%20objects%3A%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CSPAN%3EAzure%20AD%20users%20(managed%2C%20federated%26nbsp%3Band%26nbsp%3Bguest)%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3EAzure%20AD%20groups%20(managed%26nbsp%3Band%26nbsp%3Bfederated)%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3EAzure%20AD%20applications%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%3EFor%20more%20information%20on%20Azure%20AD%20applications%2C%20see%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fdevelop%2Fapp-objects-and-service-principals%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%3EApplication%20and%20service%20principal%20objects%20in%20Azure%20Active%20Directory%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%20and%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fazure%2Fcreate-azure-service-principal-azureps%3Fview%3Dazps-4.2.0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%3ECreate%20an%20Azure%20service%20principal%20with%20Azure%20PowerShell%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%3E%3CU%3E.%3C%2FU%3E%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EFormerly%2C%20only%20%3C%2FSPAN%3ESQL%20Managed%20Instance%20supported%20the%20creation%20of%20those%20Azure%20AD%20object%20types%20on%20behalf%20of%20an%20Azure%20AD%20Application%20(using%20service%20principal).%20%3CSPAN%3ESupport%20for%20this%20in%3C%2FSPAN%3E%20Azure%20SQL%20Database%20and%20Azure%20Synapse%20Analytics%20is%20now%20in%20public%20preview.%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThis%20functionality%20is%20useful%20%3C%2FSPAN%3E%3CSPAN%3Efor%20%3C%2FSPAN%3E%3CSPAN%3Eautomat%3C%2FSPAN%3E%3CSPAN%3Eed%3C%2FSPAN%3E%3CSPAN%3E%20processes%20where%20Azure%20AD%20objects%20are%20created%20and%20maintained%20in%20%3C%2FSPAN%3E%3CSPAN%3EAzure%20%3C%2FSPAN%3E%3CSPAN%3ESQL%20Database%20without%20human%20interaction%3C%2FSPAN%3E%3CSPAN%3E%20by%20Azure%20AD%20applications%3C%2FSPAN%3E%3CSPAN%3E.%20Since%20service%20principals%20could%20be%20an%20Azure%20AD%20admin%26nbsp%3Bfor%20SQL%20DB%26nbsp%3Bas%20part%20of%20a%20group%20or%20an%26nbsp%3Bindividual%26nbsp%3Buser%2C%20automated%20Azure%20AD%20object%20creation%20in%20SQL%20DB%20can%20be%20executed.%20This%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Ballows%20for%20a%20full%20automation%20of%20a%20database%20user%20creation.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EThis%20functionality%20is%20also%20supported%20for%26nbsp%3B%3C%2FSPAN%3Esystem-assigned%20managed%26nbsp%3Bidentity%26nbsp%3Band%26nbsp%3Buser-assigned%20managed%20identity%26nbsp%3B%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3Esee%20the%20article%2C%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fmanaged-identities-azure-resources%2Foverview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%3EWhat%20are%20managed%20identities%20for%20Azure%20resources%3F%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%3E).%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--631613292%22%20id%3D%22toc-hId--631613292%22%20id%3D%22toc-hId--631613292%22%20id%3D%22toc-hId--631613292%22%20id%3D%22toc-hId--631613292%22%20id%3D%22toc-hId--631613292%22%20id%3D%22toc-hId--631613292%22%3E%3CSPAN%3EPrerequisites%3C%2FSPAN%3E%3C%2FH3%3E%0A%3CP%3E%3CSPAN%3ETo%20enable%20this%20feature%2C%20the%20following%20steps%20are%20required%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E1)%26nbsp%3B%20%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EAssign%20a%20server%20identity%20during%20SQL%20logical%20server%20creation%20or%20after%20the%20server%20is%20created.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20See%20the%20PowerShell%20example%20below%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSPAN%3ETo%20create%20a%20server%20identity%20during%20the%20Azure%20SQL%26nbsp%3Blogical%26nbsp%3Bserver%26nbsp%3Bcreation%2C%20execute%26nbsp%3Bthe%20following%20command%3A%20%26nbsp%3B%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%3CSPAN%3E%3CSTRONG%3ENew-AzSqlServer%26nbsp%3B-ResourceGroupName%26nbsp%3B%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%3E%3CSTRONG%3E%3CRESOURCE%20group%3D%22%22%3E%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B-Location%26nbsp%3B%3CLOCATION%3E%26nbsp%3B-ServerName%26nbsp%3B%3CSERVER%3E%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B-ServerVersion%26nbsp%3B%2212.0%22%20-SqlAdministratorCredentials%26nbsp%3B(Get-Credential)%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B-AssignIdentity%26nbsp%3B%3C%2FSERVER%3E%3C%2FLOCATION%3E%3C%2FRESOURCE%3E%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%3E%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSTRONG%3E%3CBR%20%2F%3E%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B(See%20the%20%3CA%20href%3D%22https%3A%2F%2Fnam06.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%253A%252F%252Fdocs.microsoft.com%252Fen-us%252Fpowershell%252Fmodule%252Faz.sql%252Fnew-azsqlserver%253Fview%253Dazps-4.4.0%26amp%3Bdata%3D02%257C01%257Cmireks%2540microsoft.com%257C0822b8cb18b643a86bbd08d832947490%257C72f988bf86f141af91ab2d7cd011db47%257C1%257C0%257C637314960525109375%26amp%3Bsdata%3DtgjGSC30vxT3BnAdQ%252BUK52wrUYtxu5GkpNjGgDIToUc%253D%26amp%3Breserved%3D0%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ENew-AzSqlServer%3C%2FA%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ecommand%20for%20more%20details)%3C%2FSPAN%3E%26nbsp%3B%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSPAN%3EFor%20existing%20Azure%20SQL%20logical%20servers%2C%26nbsp%3Bexecute%20the%20following%20command%3C%2FSPAN%3E%3CSPAN%3E%3A%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%3CSPAN%3E%3CSTRONG%3ESet-AzSqlServer%26nbsp%3B-ResourceGroupName%E2%80%AF%3CRESOURCE%20group%3D%22%22%3E%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B-ServerName%E2%80%AF%3CSERVER%3E%3C%2FSERVER%3E%3C%2FRESOURCE%3E%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%3E%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%3E%3CSTRONG%3E-AssignIdentity%E2%80%AF%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B(See%20the%20%E2%80%AF%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Faz.sql%2Fset-azsqlserver%3Fview%3Dazps-3.2.0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%3ESet-AzSqlServer%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%3E%E2%80%AFcommand%26nbsp%3Bfor%20more%20details)%E2%80%AF%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3CBR%20%2F%3E%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BTo%20check%20if%20a%20server%20identity%26nbsp%3Bis%26nbsp%3Bassigned%26nbsp%3Bto%20the%26nbsp%3BAzure%20SQL%20logical%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3Bserver%2C%26nbsp%3Bexecute%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ethe%20following%26nbsp%3B%20command%3A%3CBR%20%2F%3E%3C%2FSPAN%3E%3CSPAN%3E%3CSTRONG%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BGet-AzSqlServer%20%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%3E%3CSTRONG%3E-ResourceGroupName%26nbsp%3B%3CRESOURCE%20group%3D%22%22%3E%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B-%20ServerName%26nbsp%3B%3CSERVER%3E%3C%2FSERVER%3E%3C%2FRESOURCE%3E%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%3E%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%3E%3CSTRONG%3E%3CBR%20%2F%3E%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B(See%20the%20%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Faz.sql%2Fget-azsqlserver%3Fview%3Dazps-4.3.0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EGet-AzSqlServer%3C%2FA%3E%20command%20for%20more%20details)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E2)%26nbsp%3B%20%26nbsp%3BGrant%20the%20Azure%26nbsp%3BAD%26nbsp%3B%3CSTRONG%3E%E2%80%9CDirectory%20Readers%3C%2FSTRONG%3E%E2%80%9D%20permission%20to%20the%20server%20identity%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20created%20above%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3CBR%20%2F%3E%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B(For%20more%20information%2C%20see%20%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-sql%2Fdatabase%2Fauthentication-aad-configure%3Ftabs%3Dazure-powershell%23provision-azure-ad-admin-sql-managed-instance%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%3EProvision%20Azure%20AD%20admin%20(SQL%20Managed%20Instance)%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20style%3D%22font-family%3A%20SegoeUI%2C%20Lato%2C%20'Helvetica%20Neue'%2C%20Helvetica%2C%20Arial%2C%20sans-serif%3B%20color%3A%20%23333333%3B%22%20id%3D%22toc-hId-1855899541%22%20id%3D%22toc-hId-1855899541%22%20id%3D%22toc-hId-1855899541%22%20id%3D%22toc-hId-1855899541%22%20id%3D%22toc-hId-1855899541%22%20id%3D%22toc-hId-1855899541%22%20id%3D%22toc-hId-1855899541%22%3E%3CSTRONG%3EHow%20to%20use%20it%3C%2FSTRONG%3E%3C%2FH3%3E%0A%3CP%3E%3CSPAN%3EOnce%20steps%201%20and%202%20are%20completed%2C%20an%20Azure%20AD%20application%20with%20the%20right%20permissions%20can%20create%20an%20Azure%20AD%20object%20(user%2Fgroup%20or%20service%20principal)%20in%20Azure%20SQL%20DB.%20For%20more%20information%2C%20see%20the%20step-by-step%20tutorial%20doc%20(%20see%20%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-sql%2Fdatabase%2Fauthentication-aad-service-principal-tutorial%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ETutorial%3A%20Create%20Azure%20AD%20users%20using%20Azure%20AD%20applications%3C%2FA%3E%20).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20style%3D%22font-family%3A%20SegoeUI%2C%20Lato%2C%20'Helvetica%20Neue'%2C%20Helvetica%2C%20Arial%2C%20sans-serif%3B%20color%3A%20%23333333%3B%22%20id%3D%22toc-hId-48445078%22%20id%3D%22toc-hId-48445078%22%20id%3D%22toc-hId-48445078%22%20id%3D%22toc-hId-48445078%22%20id%3D%22toc-hId-48445078%22%20id%3D%22toc-hId-48445078%22%20id%3D%22toc-hId-48445078%22%3E%3CSTRONG%3EExample%3C%2FSTRONG%3E%3C%2FH3%3E%0A%3CP%3E%3CSPAN%3EUsing%20SMI%20(System-assigned%20Managed%20Identity)%20set%20up%20as%20an%20Azure%20AD%20admin%20for%20SQL%20DB%2C%20%3CBR%20%2F%3Ecreate%20an%20Azure%20AD%20application%20as%20a%20SQL%20DB%20user.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1759009385%22%20id%3D%22toc-hId--1759009385%22%20id%3D%22toc-hId--1759009385%22%20id%3D%22toc-hId--1759009385%22%20id%3D%22toc-hId--1759009385%22%20id%3D%22toc-hId--1759009385%22%20id%3D%22toc-hId--1759009385%22%3E%3CSPAN%3E%3CSTRONG%3EPreparation%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FH3%3E%0A%3CP%3E%3CSPAN%3EEnable%20steps%201%20and%202%20indicated%20above%20for%20the%20Azure%20SQL%20logical%20server%20%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSPAN%3EIn%20the%20example%20below%2C%20the%20server%20name%20is%20%3CSTRONG%3E%E2%80%98testaadsql%E2%80%99%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3EThe%20user%20database%20created%20under%20this%20serve%20is%20%E2%80%98%3CSTRONG%3Etest%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%3E%3CSTRONG%3Edb%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%3E%3CSTRONG%3E%E2%80%99%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CUL%3E%0A%3CLI%3E%3CSPAN%3EEnable%20SMI%20on%20the%20Azure%20VM%20(see%20%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fmanaged-identities-azure-resources%2Foverview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%3EWhat%20are%20managed%20identities%20for%20Azure%20resources%3F%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%3E%3CU%3E)%3C%2FU%3E%3C%2FSPAN%3E%3CUL%3E%0A%3CLI%3E%3CSPAN%3ECopy%20the%20display%20name%20of%20the%20SMI%20which%20is%20your%20VM%20name%3C%2FSPAN%3E%3CUL%3E%0A%3CLI%3E%3CSPAN%3EIn%20the%20example%20below%2C%20the%20SMI%20name%20is%20%E2%80%98%3CSTRONG%3Emy%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%3E%3CSTRONG%3Etestvm%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%3E%E2%80%99%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3ECreate%20an%20Azure%20AD%20application%3CBR%20%2F%3E%3C%2FSPAN%3ESee%20%3CA%20style%3D%22font-family%3A%20inherit%3B%20background-color%3A%20%23ffffff%3B%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fdevelop%2Fhowto-create-service-principal-portal%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EHow%20to%3A%20Use%20the%20portal%20to%20create%20an%20Azure%20AD%20application%20and%20service%20principal%20that%20can%20access%20resources%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CUL%3E%0A%3CLI%3E%3CSPAN%3ECopy%20the%20display%20name%20of%20the%20application%3C%2FSPAN%3E%3CUL%3E%0A%3CLI%3E%3CSPAN%3EIn%20the%20example%20below%20the%20app%20name%20is%20%E2%80%98%3CSTRONG%3Emyapp%3C%2FSTRONG%3E%E2%80%99%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3EUsing%20the%20Azure%20portal%2C%20assign%20your%20SMI%20(display%20name)%20as%20an%20Azure%20AD%20admin%20for%20the%20Azure%20SQL%20logical%20server%20%26nbsp%3B(see%20the%20screenshot%20below).%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Capture.AAD.Admin.PNG%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F206704i89108A2153D9DF4B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Capture.AAD.Admin.PNG%22%20alt%3D%22Capture.AAD.Admin.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSPAN%3ECreate%20Azure%20AD%20application%20user%20in%20SQL%20DB%20on%20behalf%20of%20the%20SMI%3C%2FSPAN%3E%3CUL%3E%0A%3CLI%3E%3CSPAN%3EFrom%20your%20Azure%20VM%2C%20execute%20the%20PowerShell%20script%20indicated%20below%20that%20creates%20an%20Azure%20AD%20application%20user%20in%20SQL%20DB%20on%20behalf%20of%20the%20SMI%20that%20is%20an%20Azure%20AD%20admin%20for%20this%20server%3CBR%20%2F%3E(For%20more%20information%20on%20the%20SMI%20access%20see%20%3C%2FSPAN%3E-ERR%3AREF-NOT-FOUND-Tutorial%3A%20Use%20a%20Windows%20VM%20system-assigned%20managed%20identity%20to%20access%20Azure%20SQL)%3C%2FLI%3E%0A%3CLI%3EAlternatively%2C%20the%20SMI%20could%20be%20also%20represented%20as%20a%20regular%20Azure%20AD%20user%20created%20in%20the%20database%20%E2%80%98testdb%E2%80%99%20with%20dbo%20permissions%20allowing%20to%20create%20other%20Azure%20AD%20users%20(%20see%20an%20example%20in%20-ERR%3AREF-NOT-FOUND-Tutorial%3A%20Create%20Azure%20AD%20users%20using%20Azure%20AD%20applications%20)%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3ETo%20check%20that%20the%20user%20%E2%80%98%3CSTRONG%3Emyapp%E2%80%99%3C%2FSTRONG%3E%20was%20created%20in%20the%20database%20%3CSTRONG%3E%E2%80%98testdb%E2%80%99%20%3C%2FSTRONG%3Eyou%20can%20execute%20the%20T-SQL%20command%20%3C%2FSPAN%3E%3CSTRONG%3Eselect%3C%2FSTRONG%3E%20%3CSTRONG%3E*%3C%2FSTRONG%3E%20%3CSTRONG%3Efrom%3C%2FSTRONG%3E%20%3CSTRONG%3Esys.database_principals.%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH3%20id%3D%22toc-hId-728503448%22%20id%3D%22toc-hId-728503448%22%20id%3D%22toc-hId-728503448%22%20id%3D%22toc-hId-728503448%22%20id%3D%22toc-hId-728503448%22%20id%3D%22toc-hId-728503448%22%20id%3D%22toc-hId-728503448%22%3EPowerShell%20Script%3C%2FH3%3E%0A%3CP%3E%23%20PS%20script%20creating%20a%20SQL%20user%20%3CSPAN%3E%3CSTRONG%3Emyapp%20%3C%2FSTRONG%3Efrom%20an%20Azure%20AD%20application%20on%20behalf%20of%20SMI%20%3CSTRONG%3E%E2%80%9Cmytestvm%E2%80%9D%3C%2FSTRONG%3E%3CBR%20%2F%3E%23%26nbsp%3B%20that%20is%20also%20set%20as%20Azure%20AD%20admin%20for%20SQ%20DB%20%3CBR%20%2F%3E%3C%2FSPAN%3E%3CSPAN%3E%23%20Execute%20this%20script%20from%20the%20Azure%20VM%20with%20SMI%20name%20%E2%80%98%3C%2FSPAN%3E%3CSPAN%3E%3CSTRONG%3Emytestvm%E2%80%99%3C%2FSTRONG%3E%3C%2FSPAN%3E%20%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3CBR%20%2F%3E%3C%2FSPAN%3E%3CSPAN%3E%23%20Azure%20AD%20application%20-%20display%20name%26nbsp%3B%20%E2%80%98%3CSTRONG%3Emyapp%E2%80%99%3CBR%20%2F%3E%3C%2FSTRONG%3E%23%20This%20is%20the%20user%20name%20that%20is%20created%20in%20SQL%20DB%20%E2%80%98%3CSTRONG%3Etestdb%3C%2FSTRONG%3E%E2%80%99%20in%20the%20server%26nbsp%3B%20%3CSTRONG%3E%E2%80%98testaadsql%E2%80%99%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%23%20Metadata%20service%20endpoint%20for%20SMI%2C%20accessible%20only%20from%20within%20the%20VM%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%24response%20%3D%20Invoke-WebRequest%20-Uri%20'-ERR%3AREF-NOT-FOUND-%3CA%20href%3D%22http%3A%2F%2F169.254.169.254%2Fmetadata%2Fidentity%2Foauth2%2Ftoken%3Fapi-version%3D2018-02-01%26amp%3Bresource%3Dhttps%253A%252F%252Fdatabase.windows.net%252F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2F169.254.169.254%2Fmetadata%2Fidentity%2Foauth2%2Ftoken%3Fapi-version%3D2018-02-01%26amp%3Bresource%3Dhttps%253A%252F%252Fdatabase.windows.net%252F%3C%2FA%3E'%20-Method%20GET%20-Headers%20%40%7BMetadata%3D%22true%22%7D%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%24content%20%3D%20%24response.Content%20%7C%20ConvertFrom-Json%3CBR%20%2F%3E%24AccessToken%20%3D%20%24content.access_token%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%23%20Specify%20server%20name%20and%20database%20name%3CBR%20%2F%3E%23%20For%20the%20server%20name%2C%20the%20server%20identity%20must%20be%20assigned%20and%20%22Directory%20Readers%22%20%3CBR%20%2F%3E%23%20permission%20granted%20to%20the%20identity%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%24SQLServerName%20%3D%20%22testaadsql%22%3CBR%20%2F%3E%24DatabaseName%20%3D%20'testdb'%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%24conn%20%3D%20New-Object%20System.Data.SqlClient.SQLConnection%20%3CBR%20%2F%3E%24conn.ConnectionString%20%3D%20%22Data%20Source%3D%24SQLServerName.database.windows.net%3BInitial%20Catalog%3D%24DatabaseName%3BConnect%20Timeout%3D30%22%3CBR%20%2F%3E%24conn.AccessToken%20%3D%20%24AccessToken%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%24conn.Open()%20%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%23%20Create%20SQL%20DB%20user%20%5Bmyapp%5D%20in%20the%20%E2%80%98testdb%E2%80%99%20database%3CBR%20%2F%3E%3CSTRONG%3E%24ddlstmt%20%3D%20'CREATE%20USER%20%5Bmyapp%5D%20FROM%20EXTERNAL%20PROVIDER%3B'%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%24command%20%3D%20New-Object%20-TypeName%20System.Data.SqlClient.SqlCommand(%24ddlstmt%2C%20%24conn)%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CBR%20%2F%3EWrite-host%20%22%20%22%3CBR%20%2F%3EWrite-host%20%22SQL%20DDL%20command%20was%20executed%22%3CBR%20%2F%3E%24ddlstmt%3CBR%20%2F%3EWrite-host%20%22results%22%3CBR%20%2F%3E%24command.ExecuteNonQuery()%3CBR%20%2F%3E%24conn.Close()%26nbsp%3B%20%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EFor%20feedback%2Fquestions%20on%20this%20preview%20feature%2C%20please%20reach%20out%20to%20the%20SQL%20AAD%20team%20at%26nbsp%3B%3C%2FSPAN%3E-ERR%3AREF-NOT-FOUND-%3CSPAN%20data-contrast%3D%22none%22%3ESQLAADFeedback%40Microsoft.com%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A240%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A254%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1491121%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20SQL%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EManaged%20Instance%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESecurity%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESQL%20Server%20VM%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1564621%22%20slang%3D%22en-US%22%3ERe%3A%20Support%20for%20Azure%26nbsp%3BAD%26nbsp%3Buser%20creation%26nbsp%3Bon%20behalf%20of%20Azure%20AD%20Applications%20for%26nbsp%3BAzure%20SQL%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1564621%22%20slang%3D%22en-US%22%3E%3CP%3EGreat%20news%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F225609%22%20target%3D%22_blank%22%3E%40Mirek%20Sztajno%3C%2FA%3E%26nbsp%3B%2C%20thanks!%20A%20few%20questions%3A%3C%2FP%3E%3CUL%3E%3CLI%3EIs%20there%20a%20way%20to%20inspect%20current%20%E2%80%98server%20identity%E2%80%99%20(as%20described%20in%20prerequisites%20section)%20in%20Azure%20Portal%3F%3C%2FLI%3E%3CLI%3EIs%20there%20a%20way%20to%20set%20server%20identity%20using%20ARM%20template%3F%3C%2FLI%3E%3CLI%3EIs%20there%20any%20reason%20I%20should%20NOT%20set%20the%20same%20identity%20as%20both%20Azure%20AD%20admin%20and%20%E2%80%98server%20identity%E2%80%99%20in%20SQL%20Azure%3F%3C%2FLI%3E%3C%2FUL%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1565907%22%20slang%3D%22en-US%22%3ERe%3A%20Support%20for%20Azure%26nbsp%3BAD%26nbsp%3Buser%20creation%26nbsp%3Bon%20behalf%20of%20Azure%20AD%20Applications%20for%26nbsp%3BAzure%20SQL%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1565907%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F714226%22%20target%3D%22_blank%22%3E%40arek-avanade%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%0A%3CP%3E%231.%20There%20is%20no%20portal%20support%20currently%20in%20sql%20blade%20where%20you%20see%20server%20identity.%20If%20you%20go%20to%20AAD%20blade%20-%26gt%3B%20Enterprise%20applications%20-%26gt%3B%20all%20applications%20.%20In%20drop%20down%20select%20application%20type%20%3D%20all%20applications%2C%20there%20if%20you%20give%20server%20name%2C%20you%20can%20see%20the%20identity.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%232.%20There%20is%20an%20ARM%20API%20you%20can%20use%20to%20set%20this%20and%20plug%20it%20in%20template.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPUT%20-%20%3CA%20href%3D%22https%3A%2F%2Fmanagement.azure.com%2Fsubscriptions%2F%26lt%3BsubscriptionId%26gt%3B%2FresourceGroups%2F%26lt%3Bresource_group_name%26gt%3B%2Fproviders%2FMicr%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmanagement.azure.com%2Fsubscriptions%2F%3CSUBSCRIPTIONID%3E%2FresourceGroups%2F%3CRESOURCE_GROUP_NAME%3E%2Fproviders%2FMicr%3C%2FRESOURCE_GROUP_NAME%3E%3C%2FSUBSCRIPTIONID%3E%3C%2FA%3E%3CBR%20%2F%3Eosoft.Sql%2Fservers%2F%3CSERVER_NAME%3E%3Fapi-version%3D2019-06-01-preview%3C%2FSERVER_NAME%3E%3C%2FP%3E%0A%3CP%3EBody%3A%20%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%26nbsp%3B%20%22identity%22%3A%20%7B%3CBR%20%2F%3E%26nbsp%3B%20%22type%22%3A%20%22SystemAssigned%22%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%26nbsp%3B%20%22location%22%3A%20%22%3CSERVER%20location%3D%22%22%20like%3D%22%22%20westus%3D%22%22%3E%22%3CBR%20%2F%3E%7D%3C%2FSERVER%3E%3C%2FP%3E%0A%3CP%3E%233.%20These%20are%20different%20identities%2C%20you%20will%20not%20be%20able%20to%20use%20server%20identity%20for%20login%20as%20it%20will%20not%20let%20you%20create%20any%20secret.%26nbsp%3B%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorAmolAgarwalSQL_2%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1566578%22%20slang%3D%22en-US%22%3ERe%3A%20Support%20for%20Azure%26nbsp%3BAD%26nbsp%3Buser%20creation%26nbsp%3Bon%20behalf%20of%20Azure%20AD%20Applications%20for%26nbsp%3BAzure%20SQL%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1566578%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F680552%22%20target%3D%22_blank%22%3E%40AmolAgarwalSQL%3C%2FA%3E.%20Now%20I%20understand%20'server%20identity'%20is%20just%20like%20MSI%20that%20I%20usually%20assign%20to%20my%20App%20Services.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20realized%20there%20is%20a%20serious%20limitation%20in%20the%20above%20solution%20-%20if%20server%20identity%20needs%20to%20be%20part%20of%20Directory%20Readers%20role%20and%20I%20want%20to%20run%20all%20of%20this%20from%20build%20pipeline%2C%20that%20means%20my%20build%20agent%20needs%20to%20have%20'Global%20administrator'%20or%20'P%3CSPAN%3Erivileged%20Role%20Administrator'%20role%2C%20which%20may%20be%20a%20blocker%20in%20our%20situation...%20Such%20limitation%20doesn't%20exist%20when%20setting%20MSI%20privileges%20for%20other%20resources%2C%20and%20I'm%20wondering%20why%20this%20had%20to%20be%20done%20this%20way%20in%20SQL%20situation.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1566589%22%20slang%3D%22en-US%22%3ERe%3A%20Support%20for%20Azure%26nbsp%3BAD%26nbsp%3Buser%20creation%26nbsp%3Bon%20behalf%20of%20Azure%20AD%20Applications%20for%26nbsp%3BAzure%20SQL%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1566589%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F714226%22%20target%3D%22_blank%22%3E%40arek-avanade%3C%2FA%3E%26nbsp%3BSQL%20needs%20to%20talk%20to%20AAD%20to%20verify%20the%20AAD%20user%20that%20you%20are%20about%20to%20give%20access%20too.%20SQL%20can't%20talk%20to%20AAD%20with%20SPN%20token%20itself%20as%20AAD%20does%20not%20allow%20that%2C%20so%20only%20way%20for%20SQL%20to%20talk%20to%20AAD%20is%20to%20use%20MSI.%20And%20AAD%20only%20allows%20that%20if%20MSI%20has%20Directory%20Readers%20permissions.%20So%2C%20in%20sense%20this%20limitation%20is%20coming%20from%20AAD%20team.%20AAD%20answer%20to%20this%20is%20to%20use%26nbsp%3B%3CSPAN%3E'P%3C%2FSPAN%3E%3CSPAN%3Erivileged%20Role%20Administrator'%20role%20AFAIK.%20If%20there%20are%20scenarios%20that%20are%20still%20blocked%2C%20please%20send%20Mirek%20a%20descriptive%20email%20of%20the%20scenario%20and%20we%20will%20involve%20AAD%20team%20and%20discuss%20that.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1566634%22%20slang%3D%22en-US%22%3ERe%3A%20Support%20for%20Azure%26nbsp%3BAD%26nbsp%3Buser%20creation%26nbsp%3Bon%20behalf%20of%20Azure%20AD%20Applications%20for%26nbsp%3BAzure%20SQL%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1566634%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F680552%22%20target%3D%22_blank%22%3E%40AmolAgarwalSQL%3C%2FA%3E%26nbsp%3B%26nbsp%3BI%20understand%2C%20but%20IMHO%20the%20limitation%20is%20more%20bound%20to%20how%20MSI%20is%20handled%20on%20the%20SQL%20side.%20With%20other%20types%20of%20Azure%20resources%20I%20can%20set%20privileges%20using%20MSIs%20directly%20in%20my%20ARM%20template%2C%20so%20I'm%20guessing%20that%20the%20user%20%3CU%3Edeploying%3C%2FU%3E%26nbsp%3Bthe%20template%20needs%20to%20have%20basically%20Directory%20Readers%20role%20for%20this%20to%20work.%20Easy.%3C%2FP%3E%3CP%3EHowever%2C%20in%20SQL%20case%20there%20is%20a%20'man-in-the-middle'%20(server%20identity)%20currently%20and%20the%20user%20deploying%20the%20ARM%20template%20needs%20to%20have%20even%20higher%20privileges%20than%20Directory%20Readers%20so%20that%20he%20can%20give%20that%20permission%20to%20server%20identity.%20Ideally%20setting%20access%20to%20SQL%20based%20on%20MSIs%20should%20not%20differ%20much%20from%20doing%20the%20same%20for%20other%20Azure%20resources.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

We are announcing a public preview for Azure AD user creation support for Azure SQL Database and Azure Synapse Analytics on behalf of Azure AD Applications (service principals). See Azure Active Directory service principal with Azure SQL.


What support for Azure AD user creation on behalf of Azure AD Applications means?

Azure SQL Database, Azure Synapse Analytics (formerly SQL Data Warehouse), and SQL Managed Instance support the following Azure AD objects: 

  1. Azure AD users (managed, federated and guest) 
  2. Azure AD groups (managed and federated) 
  3. Azure AD applications  

For more information on Azure AD applications, see Application and service principal objects in Azure Active Directory  and Create an Azure service principal with Azure PowerShell. 

Formerly, only SQL Managed Instance supported the creation of those Azure AD object types on behalf of an Azure AD Application (using service principal). Support for this in Azure SQL Database and Azure Synapse Analytics is now in public preview.

This functionality is useful for automated processes where Azure AD objects are created and maintained in Azure SQL Database without human interaction by Azure AD applications. Since service principals could be an Azure AD admin for SQL DB as part of a group or an individual user, automated Azure AD object creation in SQL DB can be executed. This allows for a full automation of a database user creation. This functionality is also supported for system-assigned managed identity and user-assigned managed identity (see the article, What are managed identities for Azure resources?).

 

Prerequisites

To enable this feature, the following steps are required:

1)   Assign a server identity during SQL logical server creation or after the server is created.

      See the PowerShell example below:

  • To create a server identity during the Azure SQL logical server creation, execute the following command:  

         New-AzSqlServer -ResourceGroupName <resource group>
         -Location <Location name> -ServerName <Server name>
         -ServerVersion "12.0" -SqlAdministratorCredentials (Get-Credential)
         -AssignIdentity 
 
         (See the New-AzSqlServer command for more details)  

 

  • For existing Azure SQL logical servers, execute the following command:

         Set-AzSqlServer -ResourceGroupName <resource group>
         -ServerName <Server name>
 -AssignIdentity     
         (See the  Set-AzSqlServer command for more details)  
         To check if a server identity is assigned to the Azure SQL logical 
         server, execute 
the following  command:
         Get-AzSqlServer -ResourceGroupName <resource group> 
         - ServerName <Server name>
 
         (See the Get-AzSqlServer command for more details)

 

2)   Grant the Azure AD “Directory Readers” permission to the server identity
      created above
 
     (For more information, see Provision Azure AD admin (SQL Managed Instance) 

 

How to use it

Once steps 1 and 2 are completed, an Azure AD application with the right permissions can create an Azure AD object (user/group or service principal) in Azure SQL DB. For more information, see the step-by-step tutorial doc ( see Tutorial: Create Azure AD users using Azure AD applications ).

 

Example

Using SMI (System-assigned Managed Identity) set up as an Azure AD admin for SQL DB,
create an Azure AD application as a SQL DB user.

 

Preparation

Enable steps 1 and 2 indicated above for the Azure SQL logical server

  • In the example below, the server name is ‘testaadsql’
  • The user database created under this serve is ‘testdb
  • Copy the display name of the application
    • In the example below the app name is ‘myapp
  • Using the Azure portal, assign your SMI (display name) as an Azure AD admin for the Azure SQL logical server  (see the screenshot below).

Capture.AAD.Admin.PNG

 

 

  • Create Azure AD application user in SQL DB on behalf of the SMI
  • To check that the user ‘myapp’ was created in the database ‘testdb’ you can execute the T-SQL command select * from sys.database_principals.

PowerShell Script

# PS script creating a SQL user myapp from an Azure AD application on behalf of SMI “mytestvm”
#  that is also set as Azure AD admin for SQ DB
# Execute this script from the Azure VM with SMI name ‘mytestvm’   
# Azure AD application - display name  ‘myapp’
# This is the user name that is created in SQL DB ‘testdb’ in the server  ‘testaadsql’

# Metadata service endpoint for SMI, accessible only from within the VM:

$response = Invoke-WebRequest -Uri 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2F...' -Method GET -Headers @{Metadata="true"}

$content = $response.Content | ConvertFrom-Json
$AccessToken = $content.access_token

# Specify server name and database name
# For the server name, the server identity must be assigned and "Directory Readers"
# permission granted to the identity

$SQLServerName = "testaadsql"
$DatabaseName = 'testdb'

$conn = New-Object System.Data.SqlClient.SQLConnection
$conn.ConnectionString = "Data Source=$SQLServerName.database.windows.net;Initial Catalog=$DatabaseName;Connect Timeout=30"
$conn.AccessToken = $AccessToken

$conn.Open()

# Create SQL DB user [myapp] in the ‘testdb’ database
$ddlstmt = 'CREATE USER [myapp] FROM EXTERNAL PROVIDER;'

$command = New-Object -TypeName System.Data.SqlClient.SqlCommand($ddlstmt, $conn)      
Write-host " "
Write-host "SQL DDL command was executed"
$ddlstmt
Write-host "results"
$command.ExecuteNonQuery()
$conn.Close() 

 

For feedback/questions on this preview feature, please reach out to the SQL AAD team at SQLAADFeedback@Microsoft.com  

 

 

 

5 Comments
Frequent Visitor

Great news @Mirek Sztajno , thanks! A few questions:

  • Is there a way to inspect current ‘server identity’ (as described in prerequisites section) in Azure Portal?
  • Is there a way to set server identity using ARM template?
  • Is there any reason I should NOT set the same identity as both Azure AD admin and ‘server identity’ in SQL Azure?
Microsoft

@arek-avanade ,

#1. There is no portal support currently in sql blade where you see server identity. If you go to AAD blade -> Enterprise applications -> all applications . In drop down select application type = all applications, there if you give server name, you can see the identity. 

#2. There is an ARM API you can use to set this and plug it in template. 

PUT - https://management.azure.com/subscriptions/<subscriptionId>/resourceGroups/<resource_group_name>/pro...
osoft.Sql/servers/<server_name>?api-version=2019-06-01-preview

Body:
{
  "identity": {
  "type": "SystemAssigned"
},
  "location": "<server location like westus>"
}

#3. These are different identities, you will not be able to use server identity for login as it will not let you create any secret. 

 

 

Frequent Visitor

Thanks @AmolAgarwalSQL. Now I understand 'server identity' is just like MSI that I usually assign to my App Services.

 

I realized there is a serious limitation in the above solution - if server identity needs to be part of Directory Readers role and I want to run all of this from build pipeline, that means my build agent needs to have 'Global administrator' or 'Privileged Role Administrator' role, which may be a blocker in our situation... Such limitation doesn't exist when setting MSI privileges for other resources, and I'm wondering why this had to be done this way in SQL situation.

Microsoft

@arek-avanade SQL needs to talk to AAD to verify the AAD user that you are about to give access too. SQL can't talk to AAD with SPN token itself as AAD does not allow that, so only way for SQL to talk to AAD is to use MSI. And AAD only allows that if MSI has Directory Readers permissions. So, in sense this limitation is coming from AAD team. AAD answer to this is to use 'Privileged Role Administrator' role AFAIK. If there are scenarios that are still blocked, please send Mirek a descriptive email of the scenario and we will involve AAD team and discuss that. 

Frequent Visitor

@AmolAgarwalSQL  I understand, but IMHO the limitation is more bound to how MSI is handled on the SQL side. With other types of Azure resources I can set privileges using MSIs directly in my ARM template, so I'm guessing that the user deploying the template needs to have basically Directory Readers role for this to work. Easy.

However, in SQL case there is a 'man-in-the-middle' (server identity) currently and the user deploying the ARM template needs to have even higher privileges than Directory Readers so that he can give that permission to server identity. Ideally setting access to SQL based on MSIs should not differ much from doing the same for other Azure resources.