mcpField
A
azure-mgmt-mongodbatlas-dotnet

azure-mgmt-mongodbatlas-dotnet

github.com/sickn33クラウド・DevOps48.7k60 回インストール今日更新
リポジトリ

azure-mgmt-mongodbatlas-dotnet について

Azure Marketplace 経由の請求に対応し、MongoDB Atlas 組織を Azure ARM リソースとして管理する .NET SDK です。クラスター、データベース、コレクション、ユーザーやロールは管理しません。

主な機能

  1. 01組織リソースの作成と更新
  2. 02組織の取得と一覧表示
  3. 03タグと組織プロパティの編集
  4. 04Marketplace サブスクリプション情報の管理

活用シーン

  1. 01Azure リソースグループで Atlas 組織を作成
  2. 02組織の設定とプロビジョニング状態を確認
  3. 03組織管理者情報やリソースタグを更新

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/sickn33/agentic-awesome-skills --skill azure-mgmt-mongodbatlas-dotnet

インストール後、Claude Code で/azure-mgmt-mongodbatlas-dotnetを入力して読み込まれたか確認します。

詳細

翻訳後に原文が更新されています。最新の内容は原文をご確認ください。

Azure.ResourceManager.MongoDBAtlas SDK

Azure Marketplace を通じた統合請求により、MongoDB Atlas 組織を Azure ARM リソースとして管理します。

パッケージ情報

プロパティ値
パッケージAzure.ResourceManager.MongoDBAtlas
バージョン1.0.0 (GA)
API バージョン2025-06-01
リソースの種類MongoDB.Atlas/organizations
NuGetAzure.ResourceManager.MongoDBAtlas

インストール

dotnet add package Azure.ResourceManager.MongoDBAtlas
dotnet add package Azure.Identity
dotnet add package Azure.ResourceManager

重要なスコープの制限

この SDK は、マーケットプレース統合のために MongoDB Atlas 組織を Azure ARM リソースとして 管理します。以下を直接管理するものではありません:

  • Atlas クラスター
  • データベース
  • コレクション
  • ユーザー/ロール

クラスターの管理には、組織を作成した後に MongoDB Atlas API を直接使用してください。

認証

using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.MongoDBAtlas;
using Azure.ResourceManager.MongoDBAtlas.Models;

// Create ARM client with DefaultAzureCredential
var credential = new DefaultAzureCredential();
var armClient = new ArmClient(credential);

主要な型

型目的
MongoDBAtlasOrganizationResourceAtlas 組織を表す ARM リソース
MongoDBAtlasOrganizationCollectionリソースグループ内の組織のコレクション
MongoDBAtlasOrganizationData組織リソースのデータモデル
MongoDBAtlasOrganizationProperties組織固有のプロパティ
MongoDBAtlasMarketplaceDetailsAzure Marketplace サブスクリプションの詳細
MongoDBAtlasOfferDetailsMarketplace オファーの構成
MongoDBAtlasUserDetails組織のユーザー情報
MongoDBAtlasPartnerPropertiesMongoDB 固有のプロパティ (組織名、ID)

ワークフロー

組織コレクションの取得
// Get resource group
var subscription = await armClient.GetDefaultSubscriptionAsync();
var resourceGroup = await subscription.GetResourceGroupAsync("my-resource-group");

// Get organizations collection
MongoDBAtlasOrganizationCollection organizations = 
    resourceGroup.Value.GetMongoDBAtlasOrganizations();
組織の作成
var organizationName = "my-atlas-org";
var location = AzureLocation.EastUS2;

// Build organization data
var organizationData = new MongoDBAtlasOrganizationData(location)
{
    Properties = new MongoDBAtlasOrganizationProperties(
        marketplace: new MongoDBAtlasMarketplaceDetails(
            subscriptionId: "your-azure-subscription-id",
            offerDetails: new MongoDBAtlasOfferDetails(
                publisherId: "mongodb",
                offerId: "mongodb_atlas_azure_native_prod",
                planId: "private_plan",
                planName: "Pay as You Go (Free) (Private)",
                termUnit: "P1M",
                termId: "gmz7xq9ge3py"
            )
        ),
        user: new MongoDBAtlasUserDetails(
            emailAddress: "[email protected]",
            upn: "[email protected]"
        )
        {
            FirstName = "Admin",
            LastName = "User"
        }
    )
    {
        PartnerProperties = new MongoDBAtlasPartnerProperties
        {
            OrganizationName = organizationName
        }
    },
    Tags = { ["Environment"] = "Production" }
};

// Create the organization (long-running operation)
var operation = await organizations.CreateOrUpdateAsync(
    WaitUntil.Completed,
    organizationName,
    organizationData
);

MongoDBAtlasOrganizationResource organization = operation.Value;
Console.WriteLine($"Created: {organization.Id}");
既存の組織の取得
// Option 1: From collection
MongoDBAtlasOrganizationResource org = 
    await organizations.GetAsync("my-atlas-org");

// Option 2: From resource identifier
var resourceId = MongoDBAtlasOrganizationResource.CreateResourceIdentifier(
    subscriptionId: "subscription-id",
    resourceGroupName: "my-resource-group",
    organizationName: "my-atlas-org"
);
MongoDBAtlasOrganizationResource org2 = 
    armClient.GetMongoDBAtlasOrganizationResource(resourceId);
await org2.GetAsync(); // Fetch data
組織の一覧表示
// List in resource group
await foreach (var org in organizations.GetAllAsync())
{
    Console.WriteLine($"Org: {org.Data.Name}");
    Console.WriteLine($"  Location: {org.Data.Location}");
    Console.WriteLine($"  State: {org.Data.Properties?.ProvisioningState}");
}

// List across subscription
await foreach (var org in subscription.GetMongoDBAtlasOrganizationsAsync())
{
    Console.WriteLine($"Org: {org.Data.Name} in {org.Data.Id}");
}
タグの更新
// Add a single tag
await organization.AddTagAsync("CostCenter", "12345");

// Replace all tags
await organization.SetTagsAsync(new Dictionary<string, string>
{
    ["Environment"] = "Production",
    ["Team"] = "Platform"
});

// Remove a tag
await organization.RemoveTagAsync("OldTag");
組織プロパティの更新
var patch = new MongoDBAtlasOrganizationPatch
{
    Tags = { ["UpdatedAt"] = DateTime.UtcNow.ToString("o") },
    Properties = new MongoDBAtlasOrganizationUpdateProperties
    {
        // Update user details if needed
        User = new MongoDBAtlasUserDetails(
            emailAddress: "[email protected]",
            upn: "[email protected]"
        )
    }
};

var updateOperation = await organization.UpdateAsync(
    WaitUntil.Completed,
    patch
);
組織の削除
// Delete (long-running operation)
await organization.DeleteAsync(WaitUntil.Completed);

モデルプロパティ リファレンス

MongoDBAtlasOrganizationProperties
プロパティ型説明
MarketplaceMongoDBAtlasMarketplaceDetails必須。Marketplace サブスクリプションの詳細
UserMongoDBAtlasUserDetails必須。組織の管理者ユーザー
PartnerPropertiesMongoDBAtlasPartnerPropertiesMongoDB 固有のプロパティ
ProvisioningStateMongoDBAtlasResourceProvisioningState読み取り専用。現在のプロビジョニング状態
MongoDBAtlasMarketplaceDetails
プロパティ型説明
SubscriptionIdstring必須。請求用の Azure サブスクリプション ID
OfferDetailsMongoDBAtlasOfferDetails必須。Marketplace オファーの構成
SubscriptionStatusMarketplaceSubscriptionStatus読み取り専用。サブスクリプションの状態
MongoDBAtlasOfferDetails
プロパティ型説明
PublisherIdstring必須。発行元 ID (通常は "mongodb")
OfferIdstring必須。オファー ID
PlanIdstring必須。プラン ID
PlanNamestring必須。プランの表示名
TermUnitstring必須。請求期間の単位 (例: "P1M")
TermIdstring必須。期間識別子
MongoDBAtlasUserDetails
プロパティ型説明
EmailAddressstring必須。ユーザーのメールアドレス
Upnstring必須。ユーザープリンシパル名
FirstNamestring省略可能。ユーザーの名
LastNamestring省略可能。ユーザーの姓
MongoDBAtlasPartnerProperties
プロパティ型説明
OrganizationNamestringMongoDB Atlas 組織の名前
OrganizationIdstring読み取り専用。MongoDB Atlas 組織 ID

プロビジョニング状態

状態説明
Succeededリソースのプロビジョニングに成功しました
Failedプロビジョニングに失敗しました
Canceledプロビジョニングがキャンセルされました
Provisioningリソースをプロビジョニングしています
Updatingリソースを更新しています
Deletingリソースを削除しています
Acceptedリクエストが承認され、プロビジョニングを開始しています

マーケットプレイス サブスクリプションの状態

状態説明
PendingFulfillmentStartサブスクリプションはアクティベーション待ちです
Subscribedアクティブなサブスクリプションです
Suspendedサブスクリプションが一時停止されています
Unsubscribedサブスクリプションがキャンセルされました

ベスト プラクティス

非同期メソッドを使用する
// Prefer async for all operations
var org = await organizations.GetAsync("my-org");
await org.Value.AddTagAsync("key", "value");
実行時間の長い操作を処理する
// Wait for completion
var operation = await organizations.CreateOrUpdateAsync(
    WaitUntil.Completed,  // Blocks until done
    name,
    data
);

// Or start and poll later
var operation = await organizations.CreateOrUpdateAsync(
    WaitUntil.Started,  // Returns immediately
    name,
    data
);

// Poll for completion
while (!operation.HasCompleted)
{
    await Task.Delay(TimeSpan.FromSeconds(5));
    await operation.UpdateStatusAsync();
}
プロビジョニング状態を確認する
var org = await organizations.GetAsync("my-org");
if (org.Value.Data.Properties?.ProvisioningState == 
    MongoDBAtlasResourceProvisioningState.Succeeded)
{
    Console.WriteLine("Organization is ready");
}
リソース識別子を使用する
// Create identifier without API call
var resourceId = MongoDBAtlasOrganizationResource.CreateResourceIdentifier(
    subscriptionId,
    resourceGroupName,
    organizationName
);

// Get resource handle (no data yet)
var orgResource = armClient.GetMongoDBAtlasOrganizationResource(resourceId);

// Fetch data when needed
var response = await orgResource.GetAsync();

一般的なエラー

エラー原因解決策
ResourceNotFound組織が存在しません名前とリソース グループを確認してください
AuthorizationFailedアクセス許可が不足していますリソース グループの RBAC ロールを確認してください
InvalidParameter必須プロパティが不足していますすべての必須フィールドが設定されていることを確認してください
MarketplaceErrorマーケットプレイス サブスクリプションの問題オファーの詳細とサブスクリプションを確認してください

関連リソース

使用する場合

このスキルは、概要に記載されているワークフローまたはアクションを実行する場合に適用できます。

制限事項

  • このスキルは、タスクが上記のスコープに明確に一致する場合にのみ使用してください。
  • 出力を、環境固有の検証、テスト、または専門家によるレビューの代替として扱わないでください。
  • 必要な入力、アクセス許可、安全境界、または成功基準が不足している場合は、停止して確認を求めてください。

コメント