Chuyển đến nội dung
Skillpedia
Kiểm thử48k · #3976

azure-resource-manager-playwright-dotnet

Skill này làm gì

Đoạn mã này giúp tạo và quản lý các workspace để kiểm thử ứng dụng web bằng Playwright trên Azure. Bạn có thể thiết lập các không gian này, kiểm tra tên có còn trống không và xem giới hạn sử dụng.

Khi nào nên dùng

  • ✓Khi bạn cần tạo một môi trường mới để chạy kiểm thử Playwright tự động trên đám mây.
  • ✓Khi bạn muốn kiểm tra xem tên workspace mới đã được dùng chưa.
  • ✓Khi bạn muốn biết còn có thể tạo hoặc dùng thêm bao nhiêu tài nguyên.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-resource-manager-playwright-dotnet/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-resource-manager-playwright-dotnet/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Tạo một workspace Playwright tên “my-test-workspace” ở khu vực West US 3.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ dùng Azure SDK để kết nối với tài khoản của bạn và gửi lệnh tạo hoặc chỉnh sửa workspace. Bạn cần thiết lập danh tính và gói đăng ký Azure để công cụ biết thao tác ở đâu.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Azure.ResourceManager.Playwright (.NET)

Management plane SDK for provisioning and managing Microsoft Playwright Testing workspaces via Azure Resource Manager.

⚠️ Management vs Test Execution

  • This SDK (Azure.ResourceManager.Playwright): Create workspaces, manage quotas, check name availability
  • Test Execution SDK (Azure.Developer.MicrosoftPlaywrightTesting.NUnit): Run Playwright tests at scale on cloud browsers

Installation

dotnet add package Azure.ResourceManager.Playwright
dotnet add package Azure.Identity

Current Versions: Stable v1.0.0, Preview v1.0.0-beta.1

Environment Variables

AZURE_SUBSCRIPTION_ID=<your-subscription-id>
# For service principal auth (optional)
AZURE_TENANT_ID=<tenant-id>
AZURE_CLIENT_ID=<client-id>
AZURE_CLIENT_SECRET=<client-secret>

Authentication

using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Playwright;

// Always use DefaultAzureCredential
var credential = new DefaultAzureCredential();
var armClient = new ArmClient(credential);

// Get subscription
var subscriptionId = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID");
var subscription = armClient.GetSubscriptionResource(
    new ResourceIdentifier($"/subscriptions/{subscriptionId}"));

Resource Hierarchy

ArmClient
└── SubscriptionResource
    ├── PlaywrightQuotaResource (subscription-level quotas)
    └── ResourceGroupResource
        └── PlaywrightWorkspaceResource
            └── PlaywrightWorkspaceQuotaResource (workspace-level quotas)

Core Workflow

1. Create Playwright Workspace

using Azure.ResourceManager.Playwright;
using Azure.ResourceManager.Playwright.Models;

// Get resource group
var resourceGroup = await subscription
    .GetResourceGroupAsync("my-resource-group");

// Define workspace
var workspaceData = new PlaywrightWorkspaceData(AzureLocation.WestUS3)
{
    // Optional: Configure regional affinity and local auth
    RegionalAffinity = PlaywrightRegionalAffinity.Enabled,
    LocalAuth = PlaywrightLocalAuth.Enabled,
    Tags =
    {
        ["Team"] = "Dev Exp",
        ["Environment"] = "Production"
    }
};

// Create workspace (long-running operation)
var workspaceCollection = resourceGroup.Value.GetPlaywrightWorkspaces();
var operation = await workspaceCollection.CreateOrUpdateAsync(
    WaitUntil.Completed,
    "my-playwright-workspace",
    workspaceData);

PlaywrightWorkspaceResource workspace = operation.Value;

// Get the data plane URI for running tests
Console.WriteLine($"Data Plane URI: {workspace.Data.DataplaneUri}");
Console.WriteLine($"Workspace ID: {workspace.Data.WorkspaceId}");

2. Get Existing Workspace

// Get by name
var workspace = await workspaceCollection.GetAsync("my-playwright-workspace");

// Or check if exists first
bool exists = await workspaceCollection.ExistsAsync("my-playwright-workspace");
if (exists)
{
    var existingWorkspace = await workspaceCollection.GetAsync("my-playwright-workspace");
    Console.WriteLine($"Workspace found: {existingWorkspace.Value.Data.Name}");
}

3. List Workspaces

// List in resource group
await foreach (var workspace in workspaceCollection.GetAllAsync())
{
    Console.WriteLine($"Workspace: {workspace.Data.Name}");
    Console.WriteLine($"  Location: {workspace.Data.Location}");
    Console.WriteLine($"  State: {workspace.Data.ProvisioningState}");
    Console.WriteLine($"  Data Plane URI: {workspace.Data.DataplaneUri}");
}

// List across subscription
await foreach (var workspace in subscription.GetPlaywrightWorkspacesAsync())
{
    Console.WriteLine($"Workspace: {workspace.Data.Name}");
}

4. Update Workspace

var patch = new PlaywrightWorkspacePatch
{
    Tags =
    {
        ["Team"] = "Dev Exp",
        ["Environment"] = "Staging",
        ["UpdatedAt"] = DateTime.UtcNow.ToString("o")
    }
};

var updatedWorkspace = await workspace.Value.UpdateAsync(patch);

5. Check Name Availability

using Azure.ResourceManager.Playwright.Models;

var checkRequest = new PlaywrightCheckNameAvailabilityContent
{
    Name = "my-new-workspace",
    ResourceType = "Microsoft.LoadTestService/playwrightWorkspaces"
};

var result = await subscription.CheckPlaywrightNameAvailabilityAsync(checkRequest);

if (result.Value.IsNameAvailable == true)
{
    Console.WriteLine("Name is available!");
}
else
{

…
Câu hỏi thường gặp

Khác biệt giữa đoạn mã này và SDK để chạy kiểm thử là gì?

Đoạn mã này dùng để thiết lập và quản lý “không gian” nơi các bài kiểm thử sẽ chạy. SDK kia dùng để thực thi các bài kiểm thử bên trong những không gian đó.

Làm sao đoạn mã biết dùng tài khoản Azure nào?

Nó dùng `DefaultAzureCredential`, công cụ thử nhiều phương thức xác thực như biến môi trường hoặc đăng nhập tương tác, để kết nối với tài khoản Azure của bạn.

Tôi có thể tạo workspace ở bất kỳ đâu không?

Bạn có thể tạo workspace ở các khu vực Azure cụ thể. Đoạn mã cho phép bạn chọn khu vực mong muốn.

Chi tiết

Mô tả gốc của tác giả

Azure Resource Manager SDK for Microsoft Playwright Testing in .NET.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#3976
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự