Microsoft Azure Event Grid에 대한 Snowpipe 오류 알림 활성화하기

이 항목에서는 Snowpipe 오류 알림을 Microsoft Azure Event Grid (Event Grid)로 푸시하는 지침을 제공합니다.

이 기능은 다음 유형의 로드에 대한 오류 알림을 푸시할 수 있습니다.

  • Snowpipe 자동 수집.

  • Snowpipe insertFiles REST API 엔드포인트에 대한 호출.

  • Snowpipe 수집 방법만으로 Kafka용 Snowflake 커넥터를 사용한 Apache Kafka에서의 로드.

In this Topic:

클라우드 플랫폼 지원

현재 이 기능은 Microsoft Azure에 호스팅된 Snowflake 계정으로 제한됩니다. Snowpipe는 지원되는 모든 클라우드 저장소 서비스의 파일에서 데이터를 로딩할 수 있지만, Event Grid로의 푸시 알림은 Azure에 호스팅된 Snowflake 계정에서만 지원됩니다.

참고

  • Snowflake는 오류 알림의 메시지 전달을 한 번 이상 보장합니다(즉, 시도가 한 번 이상 성공하도록 보장하려고 메시지 전달 시도가 여러 번 이루어지므로 메시지가 중복될 수 있음).

  • 이 기능은 알림 통합 오브젝트를 사용하여 구현됩니다. 알림 통합은 Snowflake와 서드 파티 클라우드 메시지 큐 서비스 간의 인터페이스를 제공하는 Snowflake 오브젝트입니다. 단일 알림 통합은 여러 파이프를 지원할 수 있습니다.

오류 알림 활성화하기

Step 1: Creating a Custom Event Grid Topic

An Event Grid topic provides an endpoint where the source sends event notifications. Create a dedicated topic to receive error notifications published by Snowflake. You can use a single topic to receive error notifications for all pipes (for Snowpipe error notifications) or tasks (for task error notifications) in your Snowflake account.

For instructions on creating Event Grid topics, see the Event Grid documentation. Record the Event Grid topic endpoint, which you will need later in these instructions.

Optionally subscribe to the topic to inform Event Grid which events you want to track and where to send those events.

Step 2: Creating a Notification Integration in Snowflake

Retrieve the Tenant ID

Retrieve your Azure tenant ID, which you will need later in these instructions.

  1. Log into the Microsoft Azure portal.

  2. Navigate to Azure Active Directory » Properties. Record the Tenant ID value for reference later. The directory ID, or tenant ID, is needed to generate the consent URL that grants Snowflake access to the Event Grid topic.

Create the Notification Integration

Create an integration using the CREATE NOTIFICATION INTEGRATION command. An integration is a Snowflake object that references the Azure storage queue you created.

참고

Only account administrators (users with the ACCOUNTADMIN role) or a role with the global CREATE INTEGRATION privilege can execute this SQL command.

CREATE NOTIFICATION INTEGRATION <integration_name>
  ENABLED = true
  TYPE = QUEUE
  NOTIFICATION_PROVIDER = AZURE_EVENT_GRID
  DIRECTION = OUTBOUND
  AZURE_EVENT_GRID_TOPIC_ENDPOINT = '<event_grid_topic_endpoint>'
  AZURE_TENANT_ID = '<azure_tenant_id>'
Copy

예:

CREATE NOTIFICATION INTEGRATION myint
  ENABLED = true
  TYPE = QUEUE
  NOTIFICATION_PROVIDER = AZURE_EVENT_GRID
  DIRECTION = OUTBOUND
  AZURE_EVENT_GRID_TOPIC_ENDPOINT = 'https://myaccount.region-1.eventgrid.azure.net/api/events'
  AZURE_TENANT_ID = 'mytenantid';
Copy

여기서

  • event_grid_topic_endpoint is the Event Grid topic endpoint you recorded in section Step 1.

  • azure_tenant_id is your Azure directory ID, or tenant ID, which you recorded earlier in this section.

Grant Snowflake Access to the Topic

  1. Execute the DESCRIBE INTEGRATION command to retrieve the consent URL:

    DESC NOTIFICATION INTEGRATION <integration_name>;
    
    Copy

    여기서

    Note the values in the following columns:

    AZURE_CONSENT_URL:

    URL to the Microsoft permissions request page.

    AZURE_MULTI_TENANT_APP_NAME:

    Name of the Snowflake client application created for your account. In a later step in this section, you will need to grant this application the permissions necessary to obtain an access token on your allowed topic.

  2. In a web browser, navigate to the URL in the AZURE_CONSENT_URL column. The page displays a Microsoft permissions request page.

  3. Click the Accept button. This action allows the Azure service principal created for your Snowflake account to be granted an access token on specified resources inside your tenant. Obtaining an access token succeeds only if you grant the service principal the appropriate permissions on the container (see the next step).

    The Microsoft permissions request page redirects to the Snowflake corporate site (snowflake.com).

  4. Log into the Microsoft Azure portal.

  5. Navigate to Azure Active Directory » Enterprise applications. Verify the Snowflake application identifier you recorded in Step 2 in this section is listed.

    중요

    If you delete the Snowflake application in Azure Active Directory at a later time, the notification integration stops working.

  6. Navigate to Event Grid Topics » topic_name, where topic_name is the name of the topic you created to receive event notifications.

  7. Click Access Control (IAM) » Add role assignment.

  8. Search for the Snowflake service principal. This is the identity in the AZURE_MULTI_TENANT_APP_NAME property in the DESC NOTIFICATION INTEGRATION output (in Step 1). Search for the string before the underscore in the AZURE_MULTI_TENANT_APP_NAME property.

    중요

    • It can take an hour or longer for Azure to create the Snowflake service principal requested through the Microsoft request page in this section. If the service principal is not available immediately, we recommend waiting an hour or two and then searching again.

    • If you delete the service principal, the notification integration stops working.

  9. Grant the Snowflake application the EventGrid Data Sender permission.

Step 3: Enabling error notifications in pipes

여러 파이프에서 단일 알림 통합을 공유할 수 있습니다. 오류 메시지 본문을 통해서는 다른 세부 정보 중에서도 파이프, 외부 스테이지 및 경로, 오류가 발생한 파일을 파악할 수 있습니다.

파이프에 대한 오류 알림을 활성화하려면 ERROR_INTEGRATION 매개 변수 값을 지정하십시오.

참고

알림 통합을 참조하는 파이프를 만들거나 수정하려면 알림 통합에 대한 USAGE 권한이 있는 역할이 필요합니다. 또한, 역할에는 각각 스키마에 대한 CREATE PIPE 권한이나 파이프에 대한 OWNERSHIP 권한도 있어야 합니다.

스키마의 모든 오브젝트에 대해 작업하려면 상위 데이터베이스 및 스키마에 대한 USAGE 권한도 필요합니다.

지정된 권한 세트로 사용자 지정 역할을 만드는 방법에 대한 지침은 사용자 지정 역할 만들기 섹션을 참조하십시오.

보안 오브젝트 에 대해 SQL 작업을 수행하기 위한 역할과 권한 부여에 대한 일반적인 정보는 액세스 제어의 개요 섹션을 참조하십시오.

새 파이프

CREATE PIPE 를 사용하여 새 파이프를 만듭니다.

CREATE PIPE <name>
  AUTO_INGEST = TRUE
  [ INTEGRATION = '<string>' ]
  ERROR_INTEGRATION = <integration_name>
  AS <copy_statement>
Copy

여기서

ERROR_INTEGRATION = <통합_이름>

Name of the notification integration you created in Step 4: Creating the Notification Integration (in this topic).

예:

CREATE PIPE mypipe
  AUTO_INGEST = TRUE
  INTEGRATION = 'my_storage_int'
  ERROR_INTEGRATION = my_notification_int
  AS
  COPY INTO mydb.public.mytable
  FROM @mydb.public.mystage;
Copy

기존 파이프

ALTER PIPE 를 사용하여 기존 파이프를 수정합니다.

ALTER PIPE <name> SET ERROR_INTEGRATION = <integration_name>;
Copy

Where <integration_name> is the name of the notification integration you created in Step 4: Creating the Notification Integration (in this topic).

예:

ALTER PIPE mypipe SET ERROR_INTEGRATION = my_notification_int;
Copy

오류 알림 메시지 페이로드

오류 메시지의 본문에서 파이프와 로딩 중에 발생한 오류를 파악할 수 있습니다.

다음은 Snowpipe 오류를 설명하는 샘플 메시지 페이로드입니다. 페이로드는 하나 이상의 오류 메시지를 포함할 수 있습니다.

{\"version\":\"1.0\",\"messageId\":\"a62e34bc-6141-4e95-92d8-f04fe43b43f5\",\"messageType\":\"INGEST_FAILED_FILE\",\"timestamp\":\"2021-10-22T19:15:29.471Z\",\"accountName\":\"MYACCOUNT\",\"pipeName\":\"MYDB.MYSCHEMA.MYPIPE\",\"tableName\":\"MYDB.MYSCHEMA.MYTABLE\",\"stageLocation\":\"azure://myaccount.blob.core.windows.net/mycontainer/mypath\",\"messages\":[{\"fileName\":\"/file1.csv_0_0_0.csv.gz\",\"firstError\":\"Numeric value 'abc' is not recognized\"}]}
Copy

페이로드의 값을 처리하려면 문자열을 JSON 오브젝트로 구문 분석해야 합니다.