azure-mgmt-weightsandbiases-dotnet
microsoft/skills
使用 .NET SDK 在 Azure 上管理「權重與偏置」機器學習實驗追蹤實例。透過市集整合與單一登入 (SSO),建立、設定、列出、更新及刪除 W&B 實例。
...展開全部Azure.ResourceManager.WeightsAndBiases (.NET)
用於透過 Azure Marketplace 部署和管理 Weights & Biases 機器學習實驗追蹤實例的 Azure Resource Manager SDK。
安裝
dotnet add package Azure.ResourceManager.WeightsAndBiases --prerelease
dotnet add package Azure.Identity
當前版本:v1.0.0-beta.1(預覽版)
API 版本:2024-09-18-preview
環境變數
AZURE_SUBSCRIPTION_ID= # 必填:Azure 訂閱 ID
AZURE_RESOURCE_GROUP= # 必填:Azure 資源群組名稱
AZURE_WANDB_INSTANCE_NAME= # 必填:Weights & Biases 實例名稱
AZURE_TOKEN_CREDENTIALS=prod # 僅當在生產環境中使用 DefaultAzureCredential 時才為必填
驗證
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.WeightsAndBiases;
// 本地開發環境:使用 DefaultAzureCredential。生產環境:設定 AZURE_TOKEN_CREDENTIALS=prod 或 AZURE_TOKEN_CREDENTIALS=
var credential = new DefaultAzureCredential(
DefaultAzureCredential.DefaultEnvironmentVariableName
);
// 或者在生產環境中直接使用特定的憑證:
// 參閱 https://learn.microsoft.com/dotnet/api/overview/azure/identity-readme?view=azure-dotnet#credential-classes
// var credential = new ManagedIdentityCredential();
ArmClient client = new ArmClient(credential);
資源層級結構
訂閱
└── 資源群組
└── WeightsAndBiasesInstance # 來自 Azure Marketplace 的 W&B 部署
├── Properties
│ ├── Marketplace # 產品資訊、方案、發佈者
│ ├── User # 管理員使用者資訊
│ ├── PartnerProperties # W&B 專用設定(區域、子網域)
│ └── SingleSignOnPropertiesV2 # Entra ID 單一登入 (SSO) 設定
└── Identity # 託管身分識別 (可選)
核心工作流程
1. 建立 Weights & Biases 執行個體
using Azure.ResourceManager.WeightsAndBiases;
using Azure.ResourceManager.WeightsAndBiases.Models;
ResourceGroupResource resourceGroup = await client
.GetDefaultSubscriptionAsync()
.Result
.GetResourceGroupAsync("my-resource-group");
WeightsAndBiasesInstanceCollection instances = resourceGroup.GetWeightsAndBiasesInstances();
WeightsAndBiasesInstanceData data = new WeightsAndBiasesInstanceData(AzureLocation.EastUS)
{
Properties = new WeightsAndBiasesInstanceProperties
{
// 市集設定
Marketplace = new WeightsAndBiasesMarketplaceDetails
{
SubscriptionId = "",
OfferDetails = new WeightsAndBiasesOfferDetails
{
PublisherId = "wandb",
方案編號 = "wandb-pay-as-you-go",
方案名稱 = "wandb-payg",
方案名稱 = "隨用隨付",
計費週期 = "每月",
計費單位 = "P1M"
}
},
// 管理員使用者
User = new WeightsAndBiasesUserDetails
{
FirstName = "Admin",
LastName = "User",
EmailAddress = "[email protected]",
Upn = "[email protected]"
},
// W&B 專屬設定
PartnerProperties = new WeightsAndBiasesPartnerProperties
{
Region = WeightsAndBiasesRegion.EastUS,
Subdomain = "my-company-wandb"
}
},
// 可選:啟用受管身分識別
Identity = new ManagedServiceIdentity(ManagedServiceIdentityType.SystemAssigned)
};
ArmOperation operation = await instances
.CreateOrUpdateAsync(WaitUntil.Completed, "my-wandb-instance", data);
WeightsAndBiasesInstanceResource instance = operation.Value;
Console.WriteLine($"已建立 W&B 實例:{instance.Data.Name}");
Console.WriteLine($"配置狀態:{instance.Data.Properties.ProvisioningState}");
2. 取得現有實例
WeightsAndBiasesInstanceResource instance = await resourceGroup
.GetWeightsAndBiasesInstanceAsync("my-wandb-instance");
Console.WriteLine($"實例:{instance.Data.Name}");
Console.WriteLine($"位置:{instance.Data.Location}");
Console.WriteLine($"狀態:{instance.Data.Properties.ProvisioningState}");
if (instance.Data.Properties.PartnerProperties != null)
{
Console.WriteLine($"區域:{instance.Data.Properties.PartnerProperties.Region}");
Console.WriteLine($"子網域:{instance.Data.Properties.PartnerProperties.Subdomain}");
}
3. 列出所有執行個體
// 列出資源群組中的實例
await foreach (WeightsAndBiasesInstanceResource instance in
resourceGroup.GetWeightsAndBiasesInstances())
{
Console.WriteLine($"實例:{instance.Data.Name}");
Console.WriteLine($" 位置:{instance.Data.Location}");
Console.WriteLine($" 狀態:{instance.Data.Properties.ProvisioningState}");
}
// 訂閱中的清單
SubscriptionResource subscription = await client.GetDefaultSubscriptionAsync();
await foreach (WeightsAndBiasesInstanceResource instance in
subscription.GetWeightsAndBiasesInstancesAsync())
{
Console.WriteLine($"{instance.Data.Name} 位於 {instance.Id.ResourceGroupName}");
}
4. 設定單一登入 (SSO)
WeightsAndBiasesInstanceResource instance = await resourceGroup
.GetWeightsAndBiasesInstanceAsync("my-wandb-instance");
// 更新 SSO 設定
WeightsAndBiasesInstanceData updateData = instance.Data;
updateData.Properties.SingleSignOnPropertiesV2 = new WeightsAndBiasSingleSignOnPropertiesV2
{
Type = WeightsAndBiasSingleSignOnType.Saml,
State = WeightsAndBiasSingleSignOnState.Enable,
EnterpriseAppId = "",
AadDomains = { "example.com", "contoso.com" }
};
ArmOperation operation = await resourceGroup
.GetWeightsAndBiasesInstances()
.CreateOrUpdateAsync(WaitUntil.Completed, "my-wandb-instance", updateData);
5. 更新實例
WeightsAndBiasesInstanceResource 實例 = await resourceGroup
.GetWeightsAndBiasesInstanceAsync("my-wandb-instance");
// 更新標籤
WeightsAndBiasesInstancePatch 修補檔 = new WeightsAndBiasesInstancePatch
{
Tags =
{
{ "environment", "production" },
{ "team", "ml-platform" },
{ "costCenter", "CC-ML-001" }
}
};
instance = await instance.UpdateAsync(patch);
Console.WriteLine($"已更新執行個體:{instance.Data.Name}");
6. 刪除實例
WeightsAndBiasesInstanceResource instance = await resourceGroup
.GetWeightsAndBiasesInstanceAsync("my-wandb-instance");
await instance.DeleteAsync(WaitUntil.Completed);
Console.WriteLine("實例已刪除");
7. 檢查資源名稱可用性
// 建立前先檢查名稱是否可用
// (若 SDK 未提供此功能,請透過直接呼叫 ARM 來實作)
try
{
await resourceGroup.GetWeightsAndBiasesInstanceAsync("desired-name");
Console.WriteLine("名稱已被佔用");
}
catch (RequestFailedException ex) when (ex.Status == 404)
{
Console.WriteLine("名稱可用");
}
金鑰類型參考
| 類型 | 用途 |
|---|---|
WeightsAndBiasesInstanceResource |
W&B 實例資源 |
權重與偏置實例資料 |
實例配置資料 |
權重與偏置實例集合 |
實例集合 |
權重與偏置實例屬性 |
實例屬性 |
權重與偏置的市集詳情 |
市場訂閱資訊 |
權重與偏置的優惠詳情 |
市場平台報價詳情 |
權重與偏置使用者詳細資料 |
管理員使用者資訊 |
權重與偏誤合作夥伴屬性 |
W&B 專用設定 |
權重與偏置單一登入屬性 V2 |
單一登入 (SSO) 設定 |
權重與偏置實例修補程式 |
更新用修補程式 |
權重與偏置區域 |
支援的區域枚舉 |
可用區域
| 區域枚舉 | Azure 區域 |
|---|---|
WeightsAndBiasesRegion.EastUS |
美國東部 |
WeightsAndBiasesRegion.CentralUS |
美國中部 |
WeightsAndBiasesRegion.WestUS |
美國西部 |
權重與偏置區域.西歐 |
西歐 |
權重與偏置區域.日本東部 |
日本東部 |
權重與偏置區域.韓國中部 |
韓國中部 |
市集方案詳情
關於 Azure Marketplace 整合:
| 屬性 | 值 |
|---|---|
| 發佈者 ID | wandb |
| 方案 ID | wandb-隨用隨付 |
| 方案 ID | wandb-payg(隨用隨付) |
最佳實務
- 使用 DefaultAzureCredential— 自動支援多種驗證方法
- 啟用託管身分識別— 用於安全存取其他 Azure 資源
- 設定單一登入 (SSO)— 啟用 Entra ID 單一登入以確保企業安全性
- 為資源加上標籤— 使用標籤進行成本追蹤與組織管理
- 檢查配置狀態— 請於狀態顯示為「
成功」後再使用實例 - 使用適當的區域— 選擇最接近您運算資源的區域
- 透過 Azure 進行監控— 使用 Azure Monitor 監控資源狀態
錯誤處理
using Azure;
try
{
ArmOperation operation = await instances
.CreateOrUpdateAsync(WaitUntil.Completed, "my-wandb", data);
}
catch (RequestFailedException ex) when (ex.Status == 409)
{
Console.WriteLine("實例已存在或名稱衝突");
}
catch (RequestFailedException ex) when (ex.Status == 400)
{
Console.WriteLine($"配置無效:{ex.Message}");
}
catch (RequestFailedException ex)
{
Console.WriteLine($"Azure 錯誤:{ex.Status} - {ex.Message}");
}
與 W&B SDK 整合
建立 Azure 資源後,請使用 W&B Python SDK 進行實驗追蹤:
# 安裝:pip install wandb
import wandb
# 使用從 Azure 部署的實例取得的 W&B API 金鑰登入
wandb.login(host="https://my-company-wandb.wandb.ai")
# 初始化執行
run = wandb.init(project="my-ml-project")
# 記錄指標
wandb.log({"accuracy": 0.95, "loss": 0.05})
# 結束執行
run.finish()
相關 SDK
| SDK | 用途 | 安裝 |
|---|---|---|
Azure.ResourceManager.WeightsAndBiases |
權重與偏置 (W&B) 實例管理(此 SDK) | dotnet add package Azure.ResourceManager.WeightsAndBiases --prerelease |
Azure.ResourceManager.MachineLearning |
Azure ML 工作區 | dotnet add package Azure.ResourceManager.MachineLearning |
參考連結
| 資源 | URL |
|---|---|
| NuGet 套件 | https://www.nuget.org/packages/Azure.ResourceManager.WeightsAndBiases |
| W&B 文件 | https://docs.wandb.ai/ |
| Azure 市集 | https://azuremarketplace.microsoft.com/marketplace/apps/wandb.wandb-pay-as-you-go |
| GitHub 原始碼 | https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/weightsandbiases |
---
name: azure-mgmt-weightsandbiases-dotnet
description: Manage Weights & Biases ML experiment tracking instances on Azure using the .NET SDK. Create, configure, list, update, and delete W&B instances with marketplace integration and SSO.
license: MIT
---
# Azure.ResourceManager.WeightsAndBiases (.NET)
Azure Resource Manager SDK for deploying and managing Weights & Biases ML experiment tracking instances via Azure Marketplace.
## Installation
```bash
dotnet add package Azure.ResourceManager.WeightsAndBiases --prerelease
dotnet add package Azure.Identity
```
**Current Version**: v1.0.0-beta.1 (preview)
**API Version**: 2024-09-18-preview
## Environment Variables
```bash
AZURE_SUBSCRIPTION_ID=<your-subscription-id> # Required: Azure subscription ID
AZURE_RESOURCE_GROUP=<your-resource-group> # Required: Azure resource group name
AZURE_WANDB_INSTANCE_NAME=<your-wandb-instance> # Required: Weights & Biases instance name
AZURE_TOKEN_CREDENTIALS=prod # Required only if DefaultAzureCredential is used in production
```
## Authentication
```csharp
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.WeightsAndBiases;
// Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=<specific_credential>
var credential = new DefaultAzureCredential(
DefaultAzureCredential.DefaultEnvironmentVariableName
);
// Or use a specific credential directly in production:
// See https://learn.microsoft.com/dotnet/api/overview/azure/identity-readme?view=azure-dotnet#credential-classes
// var credential = new ManagedIdentityCredential();
ArmClient client = new ArmClient(credential);
```
## Resource Hierarchy
```
Subscription
└── ResourceGroup
└── WeightsAndBiasesInstance # W&B deployment from Azure Marketplace
├── Properties
│ ├── Marketplace # Offer details, plan, publisher
│ ├── User # Admin user info
│ ├── PartnerProperties # W&B-specific config (region, subdomain)
│ └── SingleSignOnPropertiesV2 # Entra ID SSO configuration
└── Identity # Managed identity (optional)
```
## Core Workflows
### 1. Create Weights & Biases Instance
```csharp
using Azure.ResourceManager.WeightsAndBiases;
using Azure.ResourceManager.WeightsAndBiases.Models;
ResourceGroupResource resourceGroup = await client
.GetDefaultSubscriptionAsync()
.Result
.GetResourceGroupAsync("my-resource-group");
WeightsAndBiasesInstanceCollection instances = resourceGroup.GetWeightsAndBiasesInstances();
WeightsAndBiasesInstanceData data = new WeightsAndBiasesInstanceData(AzureLocation.EastUS)
{
Properties = new WeightsAndBiasesInstanceProperties
{
// Marketplace configuration
Marketplace = new WeightsAndBiasesMarketplaceDetails
{
SubscriptionId = "<marketplace-subscription-id>",
OfferDetails = new WeightsAndBiasesOfferDetails
{
PublisherId = "wandb",
OfferId = "wandb-pay-as-you-go",
PlanId = "wandb-payg",
PlanName = "Pay As You Go",
TermId = "monthly",
TermUnit = "P1M"
}
},
// Admin user
User = new WeightsAndBiasesUserDetails
{
FirstName = "Admin",
LastName = "User",
EmailAddress = "[email protected]",
Upn = "[email protected]"
},
// W&B-specific configuration
PartnerProperties = new WeightsAndBiasesPartnerProperties
{
Region = WeightsAndBiasesRegion.EastUS,
Subdomain = "my-company-wandb"
}
},
// Optional: Enable managed identity
Identity = new ManagedServiceIdentity(ManagedServiceIdentityType.SystemAssigned)
};
ArmOperation<WeightsAndBiasesInstanceResource> operation = await instances
.CreateOrUpdateAsync(WaitUntil.Completed, "my-wandb-instance", data);
WeightsAndBiasesInstanceResource instance = operation.Value;
Console.WriteLine($"W&B Instance created: {instance.Data.Name}");
Console.WriteLine($"Provisioning state: {instance.Data.Properties.ProvisioningState}");
```
### 2. Get Existing Instance
```csharp
WeightsAndBiasesInstanceResource instance = await resourceGroup
.GetWeightsAndBiasesInstanceAsync("my-wandb-instance");
Console.WriteLine($"Instance: {instance.Data.Name}");
Console.WriteLine($"Location: {instance.Data.Location}");
Console.WriteLine($"State: {instance.Data.Properties.ProvisioningState}");
if (instance.Data.Properties.PartnerProperties != null)
{
Console.WriteLine($"Region: {instance.Data.Properties.PartnerProperties.Region}");
Console.WriteLine($"Subdomain: {instance.Data.Properties.PartnerProperties.Subdomain}");
}
```
### 3. List All Instances
```csharp
// List in resource group
await foreach (WeightsAndBiasesInstanceResource instance in
resourceGroup.GetWeightsAndBiasesInstances())
{
Console.WriteLine($"Instance: {instance.Data.Name}");
Console.WriteLine($" Location: {instance.Data.Location}");
Console.WriteLine($" State: {instance.Data.Properties.ProvisioningState}");
}
// List in subscription
SubscriptionResource subscription = await client.GetDefaultSubscriptionAsync();
await foreach (WeightsAndBiasesInstanceResource instance in
subscription.GetWeightsAndBiasesInstancesAsync())
{
Console.WriteLine($"{instance.Data.Name} in {instance.Id.ResourceGroupName}");
}
```
### 4. Configure Single Sign-On (SSO)
```csharp
WeightsAndBiasesInstanceResource instance = await resourceGroup
.GetWeightsAndBiasesInstanceAsync("my-wandb-instance");
// Update with SSO configuration
WeightsAndBiasesInstanceData updateData = instance.Data;
updateData.Properties.SingleSignOnPropertiesV2 = new WeightsAndBiasSingleSignOnPropertiesV2
{
Type = WeightsAndBiasSingleSignOnType.Saml,
State = WeightsAndBiasSingleSignOnState.Enable,
EnterpriseAppId = "<entra-app-id>",
AadDomains = { "example.com", "contoso.com" }
};
ArmOperation<WeightsAndBiasesInstanceResource> operation = await resourceGroup
.GetWeightsAndBiasesInstances()
.CreateOrUpdateAsync(WaitUntil.Completed, "my-wandb-instance", updateData);
```
### 5. Update Instance
```csharp
WeightsAndBiasesInstanceResource instance = await resourceGroup
.GetWeightsAndBiasesInstanceAsync("my-wandb-instance");
// Update tags
WeightsAndBiasesInstancePatch patch = new WeightsAndBiasesInstancePatch
{
Tags =
{
{ "environment", "production" },
{ "team", "ml-platform" },
{ "costCenter", "CC-ML-001" }
}
};
instance = await instance.UpdateAsync(patch);
Console.WriteLine($"Updated instance: {instance.Data.Name}");
```
### 6. Delete Instance
```csharp
WeightsAndBiasesInstanceResource instance = await resourceGroup
.GetWeightsAndBiasesInstanceAsync("my-wandb-instance");
await instance.DeleteAsync(WaitUntil.Completed);
Console.WriteLine("Instance deleted");
```
### 7. Check Resource Name Availability
```csharp
// Check if name is available before creating
// (Implement via direct ARM call if SDK doesn't expose this)
try
{
await resourceGroup.GetWeightsAndBiasesInstanceAsync("desired-name");
Console.WriteLine("Name is already taken");
}
catch (RequestFailedException ex) when (ex.Status == 404)
{
Console.WriteLine("Name is available");
}
```
## Key Types Reference
| Type | Purpose |
|------|---------|
| `WeightsAndBiasesInstanceResource` | W&B instance resource |
| `WeightsAndBiasesInstanceData` | Instance configuration data |
| `WeightsAndBiasesInstanceCollection` | Collection of instances |
| `WeightsAndBiasesInstanceProperties` | Instance properties |
| `WeightsAndBiasesMarketplaceDetails` | Marketplace subscription info |
| `WeightsAndBiasesOfferDetails` | Marketplace offer details |
| `WeightsAndBiasesUserDetails` | Admin user information |
| `WeightsAndBiasesPartnerProperties` | W&B-specific configuration |
| `WeightsAndBiasSingleSignOnPropertiesV2` | SSO configuration |
| `WeightsAndBiasesInstancePatch` | Patch for updates |
| `WeightsAndBiasesRegion` | Supported regions enum |
## Available Regions
| Region Enum | Azure Region |
|-------------|--------------|
| `WeightsAndBiasesRegion.EastUS` | East US |
| `WeightsAndBiasesRegion.CentralUS` | Central US |
| `WeightsAndBiasesRegion.WestUS` | West US |
| `WeightsAndBiasesRegion.WestEurope` | West Europe |
| `WeightsAndBiasesRegion.JapanEast` | Japan East |
| `WeightsAndBiasesRegion.KoreaCentral` | Korea Central |
## Marketplace Offer Details
For Azure Marketplace integration:
| Property | Value |
|----------|-------|
| Publisher ID | `wandb` |
| Offer ID | `wandb-pay-as-you-go` |
| Plan ID | `wandb-payg` (Pay As You Go) |
## Best Practices
1. **Use DefaultAzureCredential** — Supports multiple auth methods automatically
2. **Enable managed identity** — For secure access to other Azure resources
3. **Configure SSO** — Enable Entra ID SSO for enterprise security
4. **Tag resources** — Use tags for cost tracking and organization
5. **Check provisioning state** — Wait for `Succeeded` before using instance
6. **Use appropriate region** — Choose region closest to your compute
7. **Monitor with Azure** — Use Azure Monitor for resource health
## Error Handling
```csharp
using Azure;
try
{
ArmOperation<WeightsAndBiasesInstanceResource> operation = await instances
.CreateOrUpdateAsync(WaitUntil.Completed, "my-wandb", data);
}
catch (RequestFailedException ex) when (ex.Status == 409)
{
Console.WriteLine("Instance already exists or name conflict");
}
catch (RequestFailedException ex) when (ex.Status == 400)
{
Console.WriteLine($"Invalid configuration: {ex.Message}");
}
catch (RequestFailedException ex)
{
Console.WriteLine($"Azure error: {ex.Status} - {ex.Message}");
}
```
## Integration with W&B SDK
After creating the Azure resource, use the W&B Python SDK for experiment tracking:
```python
# Install: pip install wandb
import wandb
# Login with your W&B API key from the Azure-deployed instance
wandb.login(host="https://my-company-wandb.wandb.ai")
# Initialize a run
run = wandb.init(project="my-ml-project")
# Log metrics
wandb.log({"accuracy": 0.95, "loss": 0.05})
# Finish run
run.finish()
```
## Related SDKs
| SDK | Purpose | Install |
|-----|---------|---------|
| `Azure.ResourceManager.WeightsAndBiases` | W&B instance management (this SDK) | `dotnet add package Azure.ResourceManager.WeightsAndBiases --prerelease` |
| `Azure.ResourceManager.MachineLearning` | Azure ML workspaces | `dotnet add package Azure.ResourceManager.MachineLearning` |
## Reference Links
| Resource | URL |
|----------|-----|
| NuGet Package | https://www.nuget.org/packages/Azure.ResourceManager.WeightsAndBiases |
| W&B Documentation | https://docs.wandb.ai/ |
| Azure Marketplace | https://azuremarketplace.microsoft.com/marketplace/apps/wandb.wandb-pay-as-you-go |
| GitHub Source | https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/weightsandbiases |
所有檔案
0 個檔案安裝 azure-mgmt-weightsandbiases-dotnet
請下載並將技能檔案解壓縮至您的 .claude/skills/ 目錄中。
下載 ZIP複製儲存庫並將技能檔案複製到您的專案中。
git clone https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-dotnet/skills/azure-mgmt-weightsandbiases-dotnet # Copy SKILL.md to your .claude/skills/ directory
複製





首頁
