You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Azure SQL DB sp_invoke_external_rest_endpoint samples
2
2
3
-
(short, 1-3 sentenced, description of the project)
3
+
`sp_invoke_external_rest_endpoint` is a system stored procedure that allows native invocation of an HTTPS REST endpoint from Azure SQL DB.
4
4
5
-
## Features
5
+
For full details on this stored procedure, please take a look at the official documentation here: [sp_invoke_external_rest_endpoint (Transact-SQL)](https://learn.microsoft.com/sql/relational-databases/system-stored-procedures/sp-invoke-external-rest-endpoint-transact-sql)
6
6
7
-
This project framework provides the following features:
7
+
## Samples
8
8
9
-
* Feature 1
10
-
* Feature 2
11
-
* ...
9
+
### [Azure Functions](./azure-functions.ipynb)
12
10
13
-
## Getting Started
14
-
15
-
### Prerequisites
16
-
17
-
(ideally very short, if any)
18
-
19
-
- OS
20
-
- Library version
21
-
- ...
22
-
23
-
### Installation
24
-
25
-
(ideally very short)
26
-
27
-
- npm install [package name]
28
-
- mvn install
29
-
- ...
30
-
31
-
### Quickstart
32
-
(Add steps to get up and running quickly)
33
-
34
-
1. git clone [repository clone url]
35
-
2. cd [repository name]
36
-
3. ...
37
-
38
-
39
-
## Demo
40
-
41
-
A demo app is included to show how to use the project.
42
-
43
-
To run the demo, follow these steps:
44
-
45
-
(Add steps to start up the demo)
46
-
47
-
1.
48
-
2.
49
-
3.
50
-
51
-
## Resources
52
-
53
-
(Any additional resources or related projects)
54
-
55
-
- Link to supporting information
56
-
- Link to similar sample
57
-
- ...
11
+
- Call a public (or anonymous) Azure Function
12
+
- Call an Azure Function protected by a secret key
"Make sure to have an Azure Function deployed in Azure to run the following samples. If you need help in creating your first Azure Function, please take a look here: [Getting started with Azure Functions](https://learn.microsoft.com/azure/azure-functions/functions-get-started). \r\n",
22
+
"\r\n",
23
+
"**Please note** that the Azure Function must have an [HTTP Trigger](https://learn.microsoft.com/azure/azure-functions/functions-bindings-http-webhook) to be able to be called by Azure SQL DB: [Azure Functions HTTP trigger](https://learn.microsoft.com/azure/azure-functions/functions-bindings-http-webhook-trigger)\r\n",
24
+
"\r\n",
25
+
"In the next samples is assumed that there is an Azure Function with HTTP Trigger support deployed at `https://azure-sql-function.azurewebsites.net/api/sample-function`. To have the samples working in your environment make sure to use the URL of your Azure Function. "
"## Call an Azure Function protected by a secret key\n",
72
+
"\n",
73
+
"Azure Funtions can be protected via the usage of a \"authorization key\" that must be passed to the function in order to execution to happen: [Authorization level](https://learn.microsoft.com/azure/azure-functions/functions-bindings-http-webhook-trigger?tabs=in-process%2Cfunctionsv2&pivots=programming-language-csharp#http-auth)\n",
74
+
"\n",
75
+
"Since the authorization key is a sensitive value, it is recommended to store its value in a `DATABASE SCOPED CREDENTIAL` (more info here: [Credentials (Database Engine)](https://learn.microsoft.com/sql/relational-databases/security/authentication-access/credentials-database-engine))"
"Once the `DATABASE SCOPED CREDENTIAL` has been defined, it can be used by anyone who has been granted the `REFERENCE` permissions on it (see: [Grant permissions to use credential](https://learn.microsoft.com/sql/relational-databases/system-stored-procedures/sp-invoke-external-rest-endpoint-transact-sql?view=azuresqldb-current&tabs=request-headers#grant-permissions-to-use-credential)):"
"## Call an Azure Function protected by Azure AD\n",
142
+
"\n",
143
+
"Make sure you have enabled the Managed Identity support for the Azure SQL Server related to the database you are using to call the Azure Function, or via AZ CLI:\n",
144
+
"\n",
145
+
"```\n",
146
+
"az sql server update -g <resource-group> -n <azure-sql-server> --identity-type SystemAssigned\n",
147
+
"\n",
148
+
"```\n",
149
+
"\n",
150
+
"or via the the Azure Portal\n",
151
+
"\n",
152
+
"\n",
153
+
"\n",
154
+
"and then enable Azure AD authentication in your Azure Function as explained here: [Tutorial: Add app authentication to your web app running on Azure App Service](https://learn.microsoft.com/azure/app-service/scenario-secure-app-authentication-app-service).\n",
155
+
"\n",
156
+
"After the Azure AD principal has been enabled on Azure Function, you'll see that there is a App (client) ID available (for example: `02f5c654-0d70-4074-a82f-40d6a0dce8ff`). The provided App ID must be used to allow Azure SQL Database to correctly make the authenticated call to the Azure Function. Create a `DATABASE SCOPED CREDENTIAL` and speciofy `Managed Identity` as the `identity` value. The `secrect` value must be a flat JSON that contains the APP ID value in the `resourceid` property:"
"Once the `DATABASE SCOPED CREDENTIAL` has been defined, it can be used by anyone who has been granted the `REFERENCE` permissions on it (see: [Grant permissions to use credential](https://learn.microsoft.com/sql/relational-databases/system-stored-procedures/sp-invoke-external-rest-endpoint-transact-sql?view=azuresqldb-current&tabs=request-headers#grant-permissions-to-use-credential)):"
0 commit comments