{"id":95075,"date":"2022-11-21T17:00:03","date_gmt":"2022-11-21T17:00:03","guid":{"rendered":"https:\/\/www.red-gate.com\/simple-talk\/?p=95075"},"modified":"2022-11-21T22:19:07","modified_gmt":"2022-11-21T22:19:07","slug":"sql-server-2022-azure-ad-authentication","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/blogs\/sql-server-2022-azure-ad-authentication\/","title":{"rendered":"SQL Server 2022: Azure AD Authentication"},"content":{"rendered":"<p><strong>SQL Server 2022<\/strong> is finally GA and one of the features I was most expecting is finally available. It&#8217;s the allows Azure AD Authentication. Azure AD users can access SQL Server directly, without a second user account.<\/p>\n<p>SQL Server on premises requires <strong>Azure ARC<\/strong> to be integrated to Azure. Azure VMs, on the other hand, don&#8217;t allow the usage of Azure ARC. Microsoft waited until the last moment to enable the same feature on the <strong>SQL Server IAAS Agent Extension<\/strong>.<\/p>\n<p>Azure creates the SQL Server IAAS Agent Extension automatically for us when we create a SQL Server virtual machine. It appears as an additional Virtual Machine object. Using this object, we can control many details of SQL Server configuration inside an azure virtual machine and one of these details is the authentication method.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"722\" height=\"95\" class=\"wp-image-95076\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2022\/11\/word-image.png\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>The first requirement for the Azure AD authentication is to set an identify to the virtual machine. On the Virtual Machine, we access the Identity tab and turn on the System Assigned Managed Identity. Azure will create an identity to the VM with the same name as the VM.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"796\" height=\"447\" class=\"wp-image-95077\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2022\/11\/word-image-1.png\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2>Define the Identity Permissions<\/h2>\n<p>The VM identity needs permission to access active directory for authentication. We can set this permission by assigning the role Directory Readers to the VM account. Follow these steps to set the permissions:<\/p>\n<p>1) Access Azure Active Directory<\/p>\n<p>2) Click the Role and Administrators tab<\/p>\n<p>3) On the search text box, type &#8220;Directory&#8221; to locate the directory readers role<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"475\" class=\"wp-image-95078\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2022\/11\/word-image-2.png\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>4) Click the Directory Readers role<\/p>\n<p>5) Click the Add assignments button<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"428\" height=\"134\" class=\"wp-image-95079\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2022\/11\/word-image-3.png\" \/><\/p>\n<p>6) Locate the VM identity and click the add button<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"577\" height=\"904\" class=\"wp-image-95080\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2022\/11\/word-image-4.png\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"577\" height=\"392\" class=\"wp-image-95081\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2022\/11\/word-image-5.png\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2>Set the Azure Authentication in SQL Server 2022<\/h2>\n<p>After these steps, we can enable the Azure AD Authentication on the SQL Server IaaS agent following these steps:<\/p>\n<p>7) Access the <strong>Security Configuration<\/strong> tab<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"778\" height=\"244\" class=\"wp-image-95082\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2022\/11\/word-image-6.png\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>8) Click the <strong>Enable<\/strong> option<\/p>\n<p>9) On the <em>Managed identity type drop down<\/em>, select the identity to be used.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1050\" height=\"490\" class=\"wp-image-95083\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2022\/11\/word-image-7.png\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>10) Click the <strong>Apply<\/strong> button<\/p>\n<p>Finally, we need to give permission to Azure users to access SQL Server. We need to use SSMS to set the permissions to the Azure users. The statements are simple:<\/p>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"> <span style=\"color: blue\">CREATE<\/span>\u00a0<span style=\"color: maroon\">login<\/span>\u00a0<span style=\"color: maroon\">[dennes@dennesbufaloinfocom.onmicrosoft.com]<\/span>\u00a0<span style=\"color: blue\">FROM<\/span>\u00a0<span style=\"color: blue\">EXTERNAL<\/span>\u00a0<span style=\"color: maroon\">provider<\/span> <br \/>\n<span style=\"color: blue\">ALTER<\/span>\u00a0<span style=\"color: maroon\">server<\/span>\u00a0<span style=\"color: maroon\">role<\/span>\u00a0<span style=\"color: maroon\">sysadmin<\/span>\u00a0<span style=\"color: blue\">ADD<\/span>\u00a0<span style=\"color: maroon\">member<\/span> <br \/>\n<span style=\"color: maroon\">[dennes@dennesbufaloinfocom.onmicrosoft.com]<\/span>\u00a0 <\/span><\/div>\n<p>&nbsp;<\/p>\n<p>Of course, you will adapt the role of your users according to your need. On Azure SQL Databases we can only create users from Azure if we are connected with an Azure account. SQL Server 2022 on an Azure VM doesn&#8217;t have this requirement.<\/p>\n<h2>Conclusion<\/h2>\n<p>SQL Server 2022 is the most cloud connected SQL Server version. Most of the connected features depend on Azure ARC, but Microsoft left for the last minute to enable the features through the SQL Server IaaS agent. One example that this was a last minute feature is how difficult it is to find documentation about this configuration.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SQL Server 2022 is finally GA and one of the features I was most expecting is finally available. It&#8217;s the allows Azure AD Authentication. Azure AD users can access SQL Server directly, without a second user account. SQL Server on premises requires Azure ARC to be integrated to Azure. Azure VMs, on the other hand,&#8230;&hellip;<\/p>\n","protected":false},"author":50808,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[5364,145788,147170],"coauthors":[6810],"class_list":["post-95075","post","type-post","status-publish","format-standard","hentry","category-blogs","tag-azure","tag-azure-active-directory","tag-sql-server-2022"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/95075","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/50808"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=95075"}],"version-history":[{"count":1,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/95075\/revisions"}],"predecessor-version":[{"id":95084,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/95075\/revisions\/95084"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=95075"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=95075"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=95075"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=95075"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}