# Azure Blobストレージを使用してバッチ予測を行う

> Azure Blobストレージを使用してバッチ予測を行う - DataRobot Pythonクライアントパッケージを使用して、Azure
> Blobストレージからスコアリングするための入力ファイルを読み取り、その結果をAzureに書き戻すバッチ予測ジョブを設定します。

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.636958+00:00` (UTC).

## Primary page

- [Azure Blobストレージを使用してバッチ予測を行う](https://docs.datarobot.com/ja/docs/api/dev-learning/python/py-code-examples/prediction-examples/azure-pred.html.md): Full documentation for this topic (Markdown sidecar).

## Sections on this page

- [要件](https://docs.datarobot.com/ja/docs/api/dev-learning/python/py-code-examples/prediction-examples/azure-pred.html.md#takeaways): In-page section heading.
- [保存された資格情報の作成](https://docs.datarobot.com/ja/docs/api/dev-learning/python/py-code-examples/prediction-examples/azure-pred.html.md#create-stored-credentials): In-page section heading.
- [予測ジョブを実行する](https://docs.datarobot.com/ja/docs/api/dev-learning/python/py-code-examples/prediction-examples/azure-pred.html.md#run-the-prediction-job): In-page section heading.
- [ドキュメンテーション](https://docs.datarobot.com/ja/docs/api/dev-learning/python/py-code-examples/prediction-examples/azure-pred.html.md#documentation): In-page section heading.

## Documentation content

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

このチュートリアルでは、DataRobot Pythonクライアントパッケージ（バッチ予測APIを呼び出す）を使用してバッチ予測ジョブを設定する方法を学習します。 このジョブは、Azure Blobストレージからスコアリング用の入力ファイルを読み取り、その結果をAzureに書き戻します。 このアプローチは、基盤となるストレージが同じであるため、Azure Data Lake Storage Gen2アカウントでも機能します。

## 要件

このチュートリアルで提供されているコードを使用するには、次のものがあることを確認してください。

- Python 2.7または3.4+
- The DataRobot Python package (2.21.0+) (pypi) (conda)
- DataRobotのデプロイ
- Azureストレージアカウント
- Azureストレージコンテナ
- A scoring dataset in the storage container to use with your DataRobot deployment

## 保存された資格情報の作成

バッチ予測ジョブを実行するには、Azure Blobストレージの読み取りと書き込みに適切な資格情報が必要です。 Azureストレージアカウントの名前とアクセスキーを指定する必要があります。

1. To retrieve these credentials, select theAccess keysmenu in the Azure portal.
2. ClickShow keysto retrieve an access key. 表示されているキー（key1またはkey2）のいずれかを使用できます。
3. Use the following code to create a new credential object within DataRobot that can be used in the batch prediction job to connect to your Azure storage account. AZURE_STORAGE_ACCOUNT="YOUR AZURE STORAGE ACCOUNT NAME"AZURE_STORAGE_ACCESS_KEY="AZURE STORAGE ACCOUNT ACCESS KEY"DR_CREDENTIAL_NAME="Azure_{}".format(AZURE_STORAGE_ACCOUNT)# Create Azure-specific credentials# You can also copy the connection string, which is found below the access key in Azure.credential=dr.Credential.create_azure(name=DR_CREDENTIAL_NAME,azure_connection_string="DefaultEndpointsProtocol=https;AccountName={};AccountKey={};".format(AZURE_STORAGE_ACCOUNT,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)

## 予測ジョブを実行する

資格情報オブジェクトが作成されたら、以下のコードサンプルに示すようにバッチ予測ジョブを設定できます。

- Setintake_settingsandoutput_settingsto theazuretype.
- Forintake_settingsandoutput_settings, seturlto the files in Blob storage that you want to read and write to (the output file does not need to exist already).
- Provide the ID of the credential object that was created above.

コードサンプルは、バッチ予測ジョブを作成して実行します。 完了すると、ジョブのステータスが表示されます。 このコードは、スコアリングデータに対して予測の説明とパススルー列の両方を返すようにジョブを設定する方法も示しています。

> [!NOTE] 備考
> デプロイIDは、 [デプロイ > 予測 > 予測API](https://docs.datarobot.com/ja/docs/classic-ui/predictions/realtime/code-py.html.md) タブのサンプルコード出力（ インターフェイス を「APIクライアント」に設定）で確認できます。

```
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 our batch prediction job
# Input: Azure Blob Storage
# Output: Azure Blob Storage

job = dr.BatchPredictionJob.score(
   deployment=DEPLOYMENT_ID,
   intake_settings={
       'type': 'azure',
       'url': "https://{}.blob.core.windows.net/{}/{}".format(AZURE_STORAGE_ACCOUNT, AZURE_STORAGE_CONTAINER,AZURE_INPUT_SCORING_FILE),
       "credential_id": credential_id
   },
   output_settings={
       'type': 'azure',
       'url': "https://{}.blob.core.windows.net/{}/{}".format(AZURE_STORAGE_ACCOUNT, 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() 
```

ジョブが正常に完了すると、Azure Blobストレージコンテナーに出力ファイルが表示されます。

## ドキュメンテーション

- Prediction API overview
- DataRobot Batch Prediction API
