OCI Functions (fn)で「user configuration is missing from file」エラーが出る問題ですね。これはFn CLIの設定ファイルが正しく構成されていないことが原因です。解決方法を詳しく説明します。
【エラーの原因】
Fn CLIは~/.fn/config.yamlファイルにユーザー設定を保存しますが、このファイルが存在しないか、必要な情報が欠けているために発生します。
【解決手順】
ステップ 1: OCI CLIの設定確認
Fn CLIはOCI CLIの設定を利用します。まず、OCI CLIが正しく設定されているか確認します。bash
# OCI CLIのバージョン確認
oci --version
# OCI設定ファイルの存在確認
cat ~/.oci/config
ステップ 2: Fnコンテキストの作成
以下のコマンドでFnコンテキストを作成します:bash
fn create context \u0026lt;context-name\u0026gt; --provider oracle
例:bash
fn create context my-context --provider oracle
ステップ 3: コンテキストの使用設定bash
fn use context \u0026lt;context-name\u0026gt;
例:bash
fn use context my-context
ステップ 4: 必要な設定値を追加
以下の情報を設定します:bash
# Oracle Functions API URL
fn update context api-url https://functions.\u0026lt;region\u0026gt;.oci.oraclecloud.com
# OCIコンパートメントID
fn update context oracle.compartment-id \u0026lt;your-compartment-id\u0026gt;
# OCIプロファイル名
fn update context oracle.profile \u0026lt;profile-name\u0026gt;
# Dockerレジストリ設定
fn update context registry \u0026lt;region-key\u0026gt;.ocir.io/\u0026lt;tenancy-namespace\u0026gt;/\u0026lt;repo-name\u0026gt;
具体例:bash
# 東京リージョンの場合
fn update context api-url https://functions.ap-tokyo-1.oci.oraclecloud.com
# コンパートメントIDの設定
fn update context oracle.compartment-id ocid1.compartment.oc1..aaaaaaaa...
# DEFAULTプロファイル使用
fn update context oracle.profile DEFAULT
# レジストリ設定
fn update context registry nrt.ocir.io/your-tenancy/my-functions
ステップ 5: 設定確認bash
# 現在の設定を確認
fn list context
# 詳細設定確認
fn get config
# または直接ファイルを確認
cat ~/.fn/config.yaml
【必要な情報の取得方法】
1. コンパートメントID
- OCIコンソールで: Identity \u0026amp; Security → Compartments
- 使用したいコンパートメントをクリック → OCIDをコピー
2. Tenancy Namespacebash
oci os ns getnrt
3. リージョンキー
- 東京: icn
- ソウル: kix
- 大阪: sin
- シンガポール: ~/.fn/config.yaml
【config.yamlの例】
正しく設定された は以下のようになります:yaml
contexts:
my-context:
api-url: https://functions.ap-tokyo-1.oci.oraclecloud.com
oracle.compartment-id: ocid1.compartment.oc1..aaaaaaaa...
oracle.profile: DEFAULT
provider: oracle
registry: nrt.ocir.io/your-tenancy/my-functions
current-context: my-context
【トラブルシューティング】
もし上記で解決しない場合:
1. 環境変数を使う方法bash
export OCI_CLI_PROFILE=DEFAULT
export OCI_CLI_COMPARTMENT_ID=\u0026lt;your-compartment-id\u0026gt;
2. fnコマンドで直接指定bash
fn create app pythonapp \\
--compartment-id \u0026lt;your-compartment-id\u0026gt; \\
--config DOCKER_REGISTRY=nrt.ocir.io/your-tenancy/my-functions
3. 設定ファイルの再作成bash
# 現在の設定を削除
rm -rf ~/.fn
# 再度上記の手順で設定fn create appコマンドが正常に実行されるはずです!
【参考ドキュメント】
- OCI Functions公式ドキュメント: https://docs.oracle.com/ja-jp/iaas/Content/Functions/home.htm
- Fn Project: https://fnproject.io/
これらの手順で