Open8

Azure OpenAI ServiceをTerraformで設定する

kun432kun432

AWSの経験はそこそこあって、IaCにはTerraformをよく使用していた。

Azureさっぱりわかってない、かつ、OpenAI ServiceのIaCをやりたい、ということでいろいろ調べつつやってみる。

kun432kun432

Azure CLI

$ brew install azure-cli
$ az login

ブラウザが自動で立ち上がるのでログインする

A web browser has been opened at https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with `az login --use-device-code`.

ログイン成功するとサブスクリプションが表示される様子。

[
  {
    "cloudName": "AzureCloud",
    "homeTenantId": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    "id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    "isDefault": true,
    "managedByTenants": [],
    "name": "(サブスクリプション名)",
    "state": "Enabled",
    "tenantId": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXXX",
    "user": {
      "name": "XXXXXXXXXX@gmail.com",
      "type": "user"
    }
  }
]

試しにリソースを見てみる。

$ az resource list
[
  {
    "changedTime": "2023-07-13T00:19:51.343629+00:00",
    "createdTime": "2023-07-13T00:08:51.791899+00:00",
    "extendedLocation": null,
(snip)
    "kind": "OpenAI",
    "location": "japaneast",
    "managedBy": null,
(snip)

ホームディレクトリに.azureというディレクトリが作成される。VSCode devcontainerを使う場合はここをマウントすれば良さそう。

$ tree ~/.azure
/Users/kun432/.azure
├── az.json
├── az.sess
├── az_survey.json
├── azureProfile.json
├── clouds.config
├── commandIndex.json
├── commands
│   ├── 2023-07-14.02-19-10.login.7900.log
│   └── 2023-07-14.02-19-19.login.7915.log
├── config
├── logs
│   └── telemetry.log
├── msal_http_cache.bin
├── msal_token_cache.json
├── telemetry
│   └── cache
├── telemetry.txt
└── versionCheck.json

3 directories, 15 files