# Step 5: Create the External Function for Azure in Snowflake¶

This topic provides instructions for creating an external function object in Snowflake. This object stores information about the remote service, such as the parameters that the remote service accepts. The instructions are the same regardless of whether you are using the Azure Portal or ARM template.

Note

External functions in Snowflake are database objects, meaning they must be created in a schema in a database. To create an external function, you must have the appropriate privileges on the database and schema where you are creating the function.

For more details, see Access Control Privileges.

In this Topic:

## Create the External Function¶

This task assumes you are in the Worksheets page in the Snowflake web interface:

1. Enter a CREATE EXTERNAL FUNCTION statement. The statement should look similar to the following:

create or replace external function <external_function_name>(<parameters>)
returns variant
api_integration = <api_integration_name>
as '<invocation_url>';

2. Replace <external_function_name> with a unique function name (e.g. echo). This name must follow the rules for Object Identifiers.

In addition, record the function name in the “External Function Name” field in your tracking worksheet.

3. Replace <parameters> with the names and SQL data types of the parameters for the function, if any.

The parameters must correspond to the parameters expected by the remote service. The parameter names do not need to match, but the data types need to be compatible.

If your Azure Function uses the sample JavaScript code provided in Step 1, then the parameters are an INTEGER and a VARCHAR. For example:

a integer, b varchar


In addition, record the parameter names and data types in the “External Function Name” field in your tracking worksheet.

4. Replace <api_integration_name> with the value from the “API Integration Name” field in your tracking worksheet.

5. Replace <invocation_url> with the appropriate URL. This is the URL to which Snowflake sends the HTTP POST command in order to call the remote service and has the following format:

https://<api_management_service_name>.azure-api.net/<api_url_suffix>/<http_triggered_function_name>


The URL you use depends on whether you are using the Azure Portal or ARM template to create your external function:

Azure Portal

Use the values from the “API Management service name”, “API Management API URL suffix”, and “HTTP-Triggered Function name” fields in your tracking worksheet. For example, your URL should look similar to:

https://my-api-management-svc.azure-api.net/my-api-url-suffix/my_http_function

ARM template

Use the value from the “Azure Function HTTP Trigger URL” field in your tracking worksheet.

6. If you haven’t already, execute the CREATE EXTERNAL FUNCTION command that you entered.