{"id":1402,"date":"2022-11-16T06:00:28","date_gmt":"2022-11-16T14:00:28","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/azure-sql\/?p=1402"},"modified":"2022-11-16T06:15:48","modified_gmt":"2022-11-16T14:15:48","slug":"azure-sql-database-external-rest-endpoints-integration-public-preview","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/azure-sql\/azure-sql-database-external-rest-endpoints-integration-public-preview\/","title":{"rendered":"Azure SQL Database External REST Endpoints Integration Public Preview"},"content":{"rendered":"<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/azure-sql-integrate-with-everything.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1481\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/azure-sql-integrate-with-everything.png\" alt=\"Image azure sql integrate with everything\" width=\"1742\" height=\"971\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/azure-sql-integrate-with-everything.png 1742w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/azure-sql-integrate-with-everything-300x167.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/azure-sql-integrate-with-everything-1024x571.png 1024w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/azure-sql-integrate-with-everything-768x428.png 768w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/azure-sql-integrate-with-everything-1536x856.png 1536w\" sizes=\"(max-width: 1742px) 100vw, 1742px\" \/><\/a><\/p>\n<p>The <strong>ability to call a REST endpoint natively from Azure SQL Database<\/strong>, which was made available via an Early Adopter Preview in May, <strong>is now moving to Public Preview<\/strong>. I&#8217;m extremely happy that as of today the new system stored procedure <code>sp_invoke_external_rest_endpoint<\/code> <strong>is available to everyone, automatically and transparently: you can use it right away, from any Azure SQL Database that you may already have or that you&#8217;ll create in future<\/strong>.<\/p>\n<p>With <code>sp_invoke_external_rest_endpoint<\/code> you can call a REST endpoint, like an Azure Function, for example, with just a line of code:<\/p>\n<pre class=\"prettyprint\">declare @ret as int, @response as nvarchar(max);\r\n\r\nexec @ret = sp_invoke_external_rest_endpoint \r\n\t@method = 'GET',\r\n\t@url = 'https:\/\/my-function.azurewebsites.net\/api\/say?message=hello world',\r\n\t@response = @response output;\r\n\t\r\nselect @ret as ReturnCode, @response as Response;<\/pre>\n<p>Here&#8217;s a screenshot of the result of calling an Azure Function that provides information about local restaurants. The screenshot also shows that you can also query using GraphQL, if that is supported by the called endpoint.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/Screenshot-2022-10-19-203959-2.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-1413\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/Screenshot-2022-10-19-203959-2.png\" alt=\"sp_invoke_external_rest_endpoint invoking an Azure Funcrtion passing a GraphQL query\" width=\"1585\" height=\"720\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/Screenshot-2022-10-19-203959-2.png 1585w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/Screenshot-2022-10-19-203959-2-300x136.png 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/Screenshot-2022-10-19-203959-2-1024x465.png 1024w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/Screenshot-2022-10-19-203959-2-768x349.png 768w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2022\/11\/Screenshot-2022-10-19-203959-2-1536x698.png 1536w\" sizes=\"(max-width: 1585px) 100vw, 1585px\" \/><\/a><\/p>\n<p>Azure Function is just one of the services you can use with <code>sp_invoke_external_rest_endpoint<\/code>. In fact, you can call <strong>any<\/strong> of the following Azure services:<\/p>\n<table class=\"table table-sm\" aria-label=\"Allowed endpoints\">\n<thead>\n<tr>\n<th colspan=\"2\">Azure Service<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Azure Functions<\/td>\n<td>Azure Apps Service<\/td>\n<\/tr>\n<tr>\n<td>Azure App Service Environment<\/td>\n<td>Azure Static Web Apps<\/td>\n<\/tr>\n<tr>\n<td>Azure Logic Apps<\/td>\n<td>Azure Container Instances<\/td>\n<\/tr>\n<tr>\n<td>Azure Event Grid<\/td>\n<td>Azure Event Hubs<\/td>\n<\/tr>\n<tr>\n<td>PowerApps \/ Dataverse<\/td>\n<td>Azure Cognitive Services<\/td>\n<\/tr>\n<tr>\n<td>Power BI<\/td>\n<td>Microsoft Graph<\/td>\n<\/tr>\n<tr>\n<td>Analysis Services<\/td>\n<td>IoT Central<\/td>\n<\/tr>\n<tr>\n<td>API Management<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Aside from calling an Azure Function, as you can see, you really have a lot of options which will enable you to create more user-friendly and responsive solutions. Just a few ideas, for example:<\/p>\n<ul>\n<li>integrate with <strong>Azure Event Hubs and Azure Event Grid<\/strong> is extremely easy now to push data out of Azure SQL to make it available to event-driven solutions.<\/li>\n<li>integrate with <strong>Power BI\u00a0<\/strong>so that you can execute a DAX query using the <a href=\"https:\/\/learn.microsoft.com\/en-us\/rest\/api\/power-bi\/datasets\/execute-queries\">executeQueries<\/a>\u00a0REST endpoint and get the result right into Azure SQL DB<\/li>\n<li>invoke any REST endpoint anywhere in the world, thanks to the integration with <strong>API Management<\/strong><\/li>\n<li>send a notification to a <strong>SignalR<\/strong> website right from Azure SQL DB thanks to already mentioned Azure Function integration<\/li>\n<li>enrich your data using AI and ML models &#8211; for example to detect anomalies &#8211; via the integration with <strong>Azure Cognitive Services<\/strong><\/li>\n<\/ul>\n<p>To learn everything about <code>sp_invoke_external_rest_endpoint<\/code>, the newly added security permission needed to use it, the support for Managed Service Identities and much more, take a look at the o<span style=\"font-size: 1rem;\">fficial documentation: <\/span><a style=\"background-color: #f7f7f9; font-size: 1rem;\" href=\"https:\/\/learn.microsoft.com\/en-us\/sql\/relational-databases\/system-stored-procedures\/sp-invoke-external-rest-endpoint-transact-sql?view=azuresqldb-current\">sp_invoke_external_rest_endpoint (Transact-SQL) (Preview).<\/a><\/p>\n<p>To make it easy to start and use <code>sp_invoke_external_rest_endpoint<\/code> right away, you can also use this G<span style=\"font-size: 1rem;\">itHub Repo full of samples: <\/span><a style=\"background-color: #f7f7f9; font-size: 1rem;\" href=\"https:\/\/github.com\/Azure-Samples\/azure-sql-db-invoke-external-rest-endpoints\">azure-sql-db-invoke-external-rest-endpoints.<\/a><\/p>\n<p>Enjoy and let us know if you like this feature and how you are using it, <strong>using the comment section below to give us your feedback and to tell us how you&#8217;d like to see this feature evolving,<\/strong> in the future. If you have some specific request, make sure to add it to the <a href=\"https:\/\/feedback.azure.com\/d365community\/forum\/04fe6ee0-3b25-ec11-b6e6-000d3a4f0da0\">Azure SQL and SQL Server feedback portal<\/a>, so that other users can contribute and help us prioritize future development. Looking forward to reading your ideas!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The ability to call a REST endpoint natively from Azure SQL Database, which was made available via an Early Adopter Preview in May, is now moving to Public Preview. I&#8217;m extremely happy that as of today the new system stored procedure sp_invoke_external_rest_endpoint is available to everyone, automatically and transparently: you can use it right away, [&hellip;]<\/p>\n","protected":false},"author":24720,"featured_media":1481,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[524,522,435,504,521,520,523,410,525],"class_list":["post-1402","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-sql","tag-event-grid","tag-eventhubs","tag-functions","tag-graphql","tag-http","tag-modern","tag-power-bi","tag-rest","tag-signalr"],"acf":[],"blog_post_summary":"<p>The ability to call a REST endpoint natively from Azure SQL Database, which was made available via an Early Adopter Preview in May, is now moving to Public Preview. I&#8217;m extremely happy that as of today the new system stored procedure sp_invoke_external_rest_endpoint is available to everyone, automatically and transparently: you can use it right away, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts\/1402","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/users\/24720"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/comments?post=1402"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts\/1402\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/media\/1481"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/media?parent=1402"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/categories?post=1402"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/tags?post=1402"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}