# Azure Blob Storageからのバッチ予測ジョブの実行

> Azure Blob Storageからのバッチ予測ジョブの実行 - Azure Blob Storageからのバッチ予測ジョブの実行

This Markdown file sits beside the HTML page at the same path (with a `.md` suffix). It summarizes the topic and lists links for tools and LLM context.

Companion generated at `2026-07-15T05:55:44.913265+00:00` (UTC).

## Primary page

- [Azure Blob Storageからのバッチ予測ジョブの実行](https://docs.datarobot.com/ja/docs/classic-ui/integrations/azure/azure-blob-storage-batch-pred.html.md): Full documentation for this topic (Markdown sidecar).

## Sections on this page

- [前提条件](https://docs.datarobot.com/ja/docs/classic-ui/integrations/azure/azure-blob-storage-batch-pred.html.md#prerequisites): In-page section heading.
- [保存された資格情報をDataRobotで作成](https://docs.datarobot.com/ja/docs/classic-ui/integrations/azure/azure-blob-storage-batch-pred.html.md#create-stored-credentials-in-datarobot): In-page section heading.
- [バッチ予測ジョブの設定および実行](https://docs.datarobot.com/ja/docs/classic-ui/integrations/azure/azure-blob-storage-batch-pred.html.md#set-up-and-run-a-batch-prediction-job): In-page section heading.
- [詳細情報](https://docs.datarobot.com/ja/docs/classic-ui/integrations/azure/azure-blob-storage-batch-pred.html.md#more-information): In-page section heading.

## Documentation content

DataRobotのバッチ予測APIを使用すると、大規模なデータセットを取り込んで、予測サーバーで実行されているデプロイ済みモデルに対してスコアを付けることができます。 APIは、ファイルの入出力のための柔軟なオプションも提供します。

このページでは、 [DataRobot Pythonクライアントパッケージ](https://datarobot-public-api-client.readthedocs-hosted.com/en/v2.24.0/) を使用してバッチ予測APIを呼び出すバッチ予測ジョブを設定する方法について説明します。このジョブでは、Azure Blob Storageからファイルをスコアリングし、その結果をAzure Blob Storageに書き戻します。 この方法は、基盤となるストレージが同じであるため、Azure Data Lake Storage Gen2アカウントでも機能します。

このページのすべてのコードスニペットは、 [ダウンロードして開始できるJupyter Notebook](https://github.com/datarobot-community/ai_engineering/blob/master/batch_predictions/azure_batch_prediction.ipynb) の一部です。

## 前提条件

このコードを実行するには、以下が必要です。

- Python 2.7または3.4+
- DataRobot Pythonパッケージ（2.21.0+）（pypi）（conda）
- DataRobotのデプロイ
- Azureストレージアカウント
- Azureストレージコンテナ
- スコアリングデータセット（ストレージコンテナ内のDataRobotのデプロイでスコアリングに使用）

## 保存された資格情報をDataRobotで作成

バッチ予測ジョブには、Azureストレージアカウントの名前やアクセスキーなど、Azure Blob Storageの読み取りと書き込みを行うための資格情報が必要です。

これらの資格情報を取得するには：

1. Azure Blob StorageアカウントのAzure Portalで、アクセスキーをクリックします。
2. キーの表示をクリックし、アクセスキーを表示します。 表示されているキーのいずれか（key1またはkey2）を使用できます。
3. 次のコードを使用して、DataRobot内に新しい資格情報オブジェクトを作成します。このオブジェクトは、バッチ予測ジョブでAzureストレージアカウントに接続するために使用します。 AZURE_STORAGE_ACCOUNT="YOUR AZURE STORAGE ACCOUNT NAME"AZURE_STORAGE_ACCESS_KEY="AZURE STORAGE ACCOUNT ACCESS KEY"DR_CREDENTIAL_NAME=f"Azure_{AZURE_STORAGE_ACCOUNT}"# Create an Azure-specific Credential# The connection string is also found below the access key in Azure if you want to copy that directly.credential=dr.Credential.create_azure(name=DR_CREDENTIAL_NAME,azure_connection_string=f"DefaultEndpointsProtocol=https;AccountName={AZURE_STORAGE_ACCOUNT};AccountKey={AZURE_STORAGE_ACCESS_KEY};")# Use this code to look up the ID of the credential object created.credential_id=Noneforcredindr.Credential.list():ifcred.name==DR_CREDENTIAL_NAME:credential_id=cred.credential_idbreakprint(credential_id)

## バッチ予測ジョブの設定および実行

資格情報オブジェクトを作成したら、バッチ予測ジョブを設定できます。
入力設定と出力設定を azure タイプに設定します。
両方の属性で、読み取りと書き込みを行うBlobストレージ内のファイルへのURL（出力ファイルはすでに存在している必要はありません）と、以前に設定した資格情報オブジェクトIDを指定します。
以下のコードは、バッチ予測ジョブを作成して実行し、終了時にジョブのステータスを表示します。
このコードは、スコアリングデータに対して予測の説明とパススルー列の両方を返すようにジョブを設定する方法も示しています。

```
DEPLOYMENT_ID = 'YOUR DEPLOYMENT ID'
AZURE_STORAGE_ACCOUNT = "YOUR AZURE STORAGE ACCOUNT NAME"
AZURE_STORAGE_CONTAINER = "YOUR AZURE STORAGE ACCOUNT CONTAINER"
AZURE_INPUT_SCORING_FILE = "YOUR INPUT SCORING FILE NAME"
AZURE_OUTPUT_RESULTS_FILE = "YOUR OUTPUT RESULTS FILE NAME"

# Set up your batch prediction job
# Input: Azure Blob Storage
# Output: Azure Blob Storage

job = dr.BatchPredictionJob.score(
   deployment=DEPLOYMENT_ID,
   intake_settings={
       'type': 'azure',
       'url': f"https://{AZURE_STORAGE_ACCOUNT}.blob.core.windows.net/{AZURE_STORAGE_CONTAINER}/{AZURE_INPUT_SCORING_FILE}",
       "credential_id": credential_id
   },
   output_settings={
       'type': 'azure',
       'url': "https://{AZURE_STORAGE_ACCOUNT}.blob.core.windows.net/{AZURE_STORAGE_CONTAINER}/{AZURE_OUTPUT_RESULTS_FILE}",
       "credential_id": credential_id
   },
   # If explanations are required, uncomment the line below
   max_explanations=5,

   # If passthrough columns are required, use this line
   passthrough_columns=['column1','column2']
)

job.wait_for_completion()
job.get_status() 
```

ジョブが完了すると、出力ファイルがBlobストレージコンテナに表示されます。 これで、DataRobot Pythonクライアントパッケージとバッチ予測APIを介して、Azure Blob Storageから読み書きできるバッチ予測ジョブができました。

## 詳細情報

- コミュニティGitHubサンプルコード
- DataRobot Pythonクライアントによるバッチ予測メソッド
