azure-mgmt-mongodbatlas-dotnet について
Azure Marketplace 経由の請求に対応し、MongoDB Atlas 組織を Azure ARM リソースとして管理する .NET SDK です。クラスター、データベース、コレクション、ユーザーやロールは管理しません。
主な機能
- 01組織リソースの作成と更新
- 02組織の取得と一覧表示
- 03タグと組織プロパティの編集
- 04Marketplace サブスクリプション情報の管理
活用シーン
- 01Azure リソースグループで Atlas 組織を作成
- 02組織の設定とプロビジョニング状態を確認
- 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 |
| NuGet | Azure.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);
主要な型
| 型 | 目的 |
|---|---|
MongoDBAtlasOrganizationResource | Atlas 組織を表す ARM リソース |
MongoDBAtlasOrganizationCollection | リソースグループ内の組織のコレクション |
MongoDBAtlasOrganizationData | 組織リソースのデータモデル |
MongoDBAtlasOrganizationProperties | 組織固有のプロパティ |
MongoDBAtlasMarketplaceDetails | Azure Marketplace サブスクリプションの詳細 |
MongoDBAtlasOfferDetails | Marketplace オファーの構成 |
MongoDBAtlasUserDetails | 組織のユーザー情報 |
MongoDBAtlasPartnerProperties | MongoDB 固有のプロパティ (組織名、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
| プロパティ | 型 | 説明 |
|---|---|---|
Marketplace | MongoDBAtlasMarketplaceDetails | 必須。Marketplace サブスクリプションの詳細 |
User | MongoDBAtlasUserDetails | 必須。組織の管理者ユーザー |
PartnerProperties | MongoDBAtlasPartnerProperties | MongoDB 固有のプロパティ |
ProvisioningState | MongoDBAtlasResourceProvisioningState | 読み取り専用。現在のプロビジョニング状態 |
MongoDBAtlasMarketplaceDetails
| プロパティ | 型 | 説明 |
|---|---|---|
SubscriptionId | string | 必須。請求用の Azure サブスクリプション ID |
OfferDetails | MongoDBAtlasOfferDetails | 必須。Marketplace オファーの構成 |
SubscriptionStatus | MarketplaceSubscriptionStatus | 読み取り専用。サブスクリプションの状態 |
MongoDBAtlasOfferDetails
| プロパティ | 型 | 説明 |
|---|---|---|
PublisherId | string | 必須。発行元 ID (通常は "mongodb") |
OfferId | string | 必須。オファー ID |
PlanId | string | 必須。プラン ID |
PlanName | string | 必須。プランの表示名 |
TermUnit | string | 必須。請求期間の単位 (例: "P1M") |
TermId | string | 必須。期間識別子 |
MongoDBAtlasUserDetails
| プロパティ | 型 | 説明 |
|---|---|---|
EmailAddress | string | 必須。ユーザーのメールアドレス |
Upn | string | 必須。ユーザープリンシパル名 |
FirstName | string | 省略可能。ユーザーの名 |
LastName | string | 省略可能。ユーザーの姓 |
MongoDBAtlasPartnerProperties
| プロパティ | 型 | 説明 |
|---|---|---|
OrganizationName | string | MongoDB Atlas 組織の名前 |
OrganizationId | string | 読み取り専用。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 | マーケットプレイス サブスクリプションの問題 | オファーの詳細とサブスクリプションを確認してください |
関連リソース
使用する場合
このスキルは、概要に記載されているワークフローまたはアクションを実行する場合に適用できます。
制限事項
- このスキルは、タスクが上記のスコープに明確に一致する場合にのみ使用してください。
- 出力を、環境固有の検証、テスト、または専門家によるレビューの代替として扱わないでください。
- 必要な入力、アクセス許可、安全境界、または成功基準が不足している場合は、停止して確認を求めてください。
コメント
Markdown 対応