Share via


파일 서비스를 사용하여 Azure Data Manager for Energy에서 파일을 업로드하는 방법

이 문서에서는 Microsoft Azure Data Manager for Energy에서 파일 서비스 API를 사용하여 대용량 파일(5GB 미만)을 업로드하는 방법을 알아봅니다. 업로드 프로세스에는 File API에서 서명된 URL을 가져온 다음 서명된 URL을 사용하여 Azure Blob Storage에 파일을 저장하는 작업이 포함됩니다.

서명된 URL 생성

Azure Cloud Bash에서 아래 curl 명령을 실행하여 Azure Data Manager for Energy 리소스의 지정된 데이터 파티션에 대한 파일 서비스에서 서명된 URL을 가져옵니다.

    curl --location 'https://<URI>/api/file/v2/files/uploadURL' \
    --header 'data-partition-id: <data-partition-id>' \
    --header 'Authorization: Bearer <access_token>' \
    --header 'Content-Type: text/plain'

샘플 요청

"dp1"이라는 데이터 파티션이 있는 "medstest"라는 Azure Data Manager for Energy 리소스를 고려합니다.

    curl --location --request POST 'https://medstest.energy.azure.com/api/file/v2/files/uploadURL' \
    --header 'data-partition-id: medstest-dp1' \
    --header 'Authorization: Bearer  eyxxxxxxx.........................' \
    --header 'Content-Type: text/plain'

샘플 응답

{
    "FileID": "2c5e7ac738a64eaeb7c0bc8bd47f90b6",
    "Location": {
        "SignedURL": "https://dummy.bloburl.com",
        "FileSource": "/osdu-user/1686647303778-2023-06-13-09-08-23-778/2c5e7ac738a64eaeb7c0bc8bd47f90b6"
    }
}

그런 다음, 응답 개체의 SignedURL 키를 사용하여 Azure Blob Storage에 파일을 업로드할 수 있습니다.

크기가 5GB 미만인 파일 업로드

5GB 미만의 파일을 업로드하려면 PUT Blob API 호출을 직접 사용하여 파일을 Azure Blob Storage에 업로드할 수 있습니다.

샘플 Curl 요청

    curl --location --request PUT '<SIGNED_URL>' \
    --header 'x-ms-blob-type: BlockBlob' \
    --header 'Content-Type: <file_type>' \ # for instance application/zip or application/csv or application/json depending on file type
    --data '@/<path_to_file>'

업로드에 성공하면 응답에 201 Created 상태 코드가 표시됩니다.

크기가 5GB 이상인 파일 업로드

단일 PUT blob 호출이 5GB를 초과할 수 없으므로 크기가 >= 5GB인 파일을 업로드하려면 azcopy 유틸리티가 필요합니다. 문서 링크

단계

  1. 링크를 사용하여 azcopy 다운로드

  2. 이 명령을 실행하여 파일 업로드

    azcopy copy "<path_to_file>" "signed_url"
  1. 샘플 응답
    INFO: Could not read destination length. If the destination is write-only, use --check-length=false on the command line.
    100.0 %, 1 Done, 0 Failed, 0 Pending, 0 Skipped, 1 Total
    
    Job 624c59e8-9d5c-894a-582f-ef9d3fb3091d summary
    Elapsed Time (Minutes): 0.1002
    Number of File Transfers: 1
    Number of Folder Property Transfers: 0
    Number of Symlink Transfers: 0
    Total Number of Transfers: 1
    Number of File Transfers Completed: 1
    Number of Folder Transfers Completed: 0
    Number of File Transfers Failed: 0
    Number of Folder Transfers Failed: 0
    Number of File Transfers Skipped: 0
    Number of Folder Transfers Skipped: 0
    TotalBytesTransferred: 1367301
    Final Job Status: Completed

다음 단계

데이터를 Azure Data Manager for Energy 리소스에 수집하여 사용자 경험을 시작합니다.