对 Azure 外部函数进行故障排除¶
本主题提供有关 Azure 外部函数的故障排除信息。
Platform-independent Runtime Issues¶
Data Type Return Values Do Not Match Expected Return Values¶
When passing arguments to or from an external function, ensure that the data types are appropriate. If the value sent can’t fit into the data type being received, the value might be truncated or corrupted in some other way.
For more details, see Ensure that arguments to the external function correspond to arguments parsed by the remote service.
Error: Row numbers out of order¶
- Possible Causes:
The row numbers you return within each batch should be monotonically ascending integers starting at 0. The input row numbers must also follow this rule, and each output row should match the corresponding input row. For example, the output in output row 0 should correspond to the input in input row 0.
- Possible Solutions:
Ensure that the row numbers you return are the same as the row numbers you received, and that each output value uses the row number of the corresponding input. If this doesn’t work, then the input row numbers may not be correct or you did not return the rows in the correct order.
Next, ensure that the output row numbers start from 0, increase by 1, and are in order.
For more information about data input and output formats, see When Snowflake sends data to a remote service, or receives data from a remote.
Error: “Error parsing JSON: Invalid response”¶
- Possible Causes:
The most likely cause is that the JSON returned by the remote service (e.g. AWS Lambda function) is not constructed correctly.
- Possible Solutions:
Ensure that the external function returns an array of arrays, with one inner array returned for each input row received. Review the description of the output format at Data format received by Snowflake.
Error: Format of the returned value is not JSON¶
- Possible Causes:
Your return value includes double quotes inside the value.
- Possible Solutions:
Although JSON strings are delimited by double quotes, the string itself should not start and end with a quotation mark in most cases. If the embedded double quotes are incorrect, remove them.
Error: Function received the wrong number of rows¶
- Possible Causes:
The remote service tried to return more or fewer rows than it received. Even though the function is nominally scalar, it might receive multiple rows in the
bodyfield of theeventparameter, and should return exactly as many rows as it received.- Possible Solution(s):
Ensure that the remote service returns one row for each row that it receives.
特定于 Azure 的问题¶
在创建 Azure 函数的过程中不能修改设置¶
- Possible Causes:
When creating your Azure Function, you may not be able to modify settings for the function under the Authentication/Authorization menu.
This problem can occur if all of the following are true:
- Azure 函数基于 Linux 运行,而非 Microsoft Windows。
- 您计划对 Azure 函数使用 Azure AD 身份验证/授权。
- 您使用的是 Azure 的“消费”定价层级,而非“高级”定价层级。
针对 Azure 函数,Azure AD 身份验证在 Linux 消费计划中不可用。您必须使用应用程序服务定价方案或高级定价方案,才能通过 Azure AD 进行身份验证。
- Possible Solutions:
-
重新创建 Azure 函数,并指定它将基于 Microsoft Windows 而非 Linux 运行。
-
跳过 Azure 函数的 Azure AD 身份验证/授权;改为执行以下任务:
- Set a validate-JWT (JSON Web Token) Policy for the API Management instance as documented in Step 6: Create the Azure security policy for the proxy service in the Portal.
- Use IP address restrictions to limit the remote service to accept connections only from the API Management service instance.
如果选择此解决方案,必须手动创建 Azure AD 应用程序。有关详细信息,请参阅 Microsoft 文档:
app registration (https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app) .
If you create the Azure AD application manually, record the
Azure Function AD app registration nameand theAzure Function App AD Application IDin your tracking worksheet.- 从消费定价切换到高级定价,或使用应用程序服务方案。有关更多详细信息,请参阅 Microsoft 文档: configuring an authentication provider (https://docs.microsoft.com/en-us/azure/app-service/configure-authentication-provider-aad)
-
外部函数超时
- Possible Causes:
可能引发超时的原因有很多。在 Azure 上,可能的原因之一是 Azure Functions 应用程序的编写方式不支持正确扩展。
- Possible Solutions:
Ensure that you are following the Azure guidelines for writing scalable functions (https://docs.microsoft.com/en-us/azure/azure-functions/functions-best-practices#scalability-best-practices) .
For more information about troubleshooting scalability and performance issues, see Troubleshooting scalability and performance issues .
Error: Failed to obtain Azure active directory access token.¶
- Possible Solutions:
请尝试以下步骤:
- 验证 Snowflake 服务主体是否有访问 Azure AD 租户的权限。
- 验证租户 ID 和 Azure AD 应用程序 ID 是否正确。
请注意,空格(包括前导和尾随空格(例如空白))在 ID 字段中非常重要。检查是否有前导或尾随空格不正确之处。
Error: 401 ‘{ “statusCode”: 401, “message”: “Access denied due to missing subscription key…” }’¶
完整的错误消息文本:
- Possible Causes:
API 管理服务的订阅要求可能处于待处理状态。
- Possible Solutions:
您可能需要关闭 API 管理服务的订阅要求。
Error: 401 ‘{ “statusCode”: 401, “message”: “Access denied due to missing subscription key.” }¶
- Possible Causes:
The proxy service requires an API key (aka “subscription key”), typically for authentication or billing. However, no API key was supplied in the API_KEY clause of the CREATE API INTEGRATION command.
- Possible Solutions:
使用 ALTER API INTEGRATION 命令,用有效的 API 密钥更新 API 集成。
Error: 401 ‘{ “statusCode”: 401, “message”: “Access denied due to invalid subscription key.” }’¶
- Possible Causes:
The proxy service requires an API key (aka “subscription key”), typically for authentication or billing. However, the API key supplied in the API_KEY clause of the CREATE API INTEGRATION command was not valid.
- Possible Solutions:
使用 ALTER API INTEGRATION 命令,用有效的 API 密钥更新 API 集成。
Error: 401 ‘{ “statusCode”: 401, “message”: “Invalid JWT.” }’¶
完整的错误消息文本:
- Possible Causes:
-
您可能尚未在 Azure API 管理服务上完成安全策略设置。例如,您可能有以下问题:
- 已创建但未编辑的 JWT (JSON Web 令牌)。
- 忽略了一个或多个必需的声明/值。例如,您可能指定了针对 Snowflake 的声明,但未指定
- 远程服务(Azure 函数),反之亦然。
-
您可能使用了无效的打开 ID URL。
-
- Possible Solutions:
- Finish setting the security policy on the Azure API Management service. For example, review the JWT and verify that you included the required claims/values, including the claim for Snowflake and the claim for the remote service (Azure Function).
- 验证是否使用了有效的打开 ID URL。
Error (remote service): 401 ‘{ “statusCode”: 401, “message”: “Invalid JWT.” }’¶
完整的错误消息文本:
- Possible Causes:
如果您使用了 ARM 模板,则可能尚未更新由模板为您创建的 JWT (JSON Web 令牌)。
- Possible Solutions:
Update the JWT as documented in Step 6: Update the Azure security policy for the proxy service in the Portal.
错误:500 …¶
- Possible Causes:
您可能为 Azure AD 应用程序选择了错误的选项:
- Incorrect option: Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)
- Correct option: Accounts in this organizational directory only (Default Directory only - Single tenant)