[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-299eb04f-416f-482d-952e-a5174ce8062e":3,"$fRjnVLyqwiah9xXHtG19_7MOeXtv-5qhncqfiyE_fTmg":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"299eb04f-416f-482d-952e-a5174ce8062e","azure-resource-manager-playwright-dotnet","Azure资源管理器SDK用于.NET的Microsoft Playwright测试。","cat_coding_devops","mod_coding","sickn33,coding","---\nname: azure-resource-manager-playwright-dotnet\ndescription: Azure Resource Manager SDK for Microsoft Playwright Testing in .NET.\nrisk: unknown\nsource: community\ndate_added: '2026-02-27'\n---\n\n# Azure.ResourceManager.Playwright (.NET)\n\nManagement plane SDK for provisioning and managing Microsoft Playwright Testing workspaces via Azure Resource Manager.\n\n> **⚠️ Management vs Test Execution**\n> - **This SDK (Azure.ResourceManager.Playwright)**: Create workspaces, manage quotas, check name availability\n> - **Test Execution SDK (Azure.Developer.MicrosoftPlaywrightTesting.NUnit)**: Run Playwright tests at scale on cloud browsers\n\n## Installation\n\n```bash\ndotnet add package Azure.ResourceManager.Playwright\ndotnet add package Azure.Identity\n```\n\n**Current Versions**: Stable v1.0.0, Preview v1.0.0-beta.1\n\n## Environment Variables\n\n```bash\nAZURE_SUBSCRIPTION_ID=\u003Cyour-subscription-id>\n# For service principal auth (optional)\nAZURE_TENANT_ID=\u003Ctenant-id>\nAZURE_CLIENT_ID=\u003Cclient-id>\nAZURE_CLIENT_SECRET=\u003Cclient-secret>\n```\n\n## Authentication\n\n```csharp\nusing Azure.Identity;\nusing Azure.ResourceManager;\nusing Azure.ResourceManager.Playwright;\n\n\u002F\u002F Always use DefaultAzureCredential\nvar credential = new DefaultAzureCredential();\nvar armClient = new ArmClient(credential);\n\n\u002F\u002F Get subscription\nvar subscriptionId = Environment.GetEnvironmentVariable(\"AZURE_SUBSCRIPTION_ID\");\nvar subscription = armClient.GetSubscriptionResource(\n    new ResourceIdentifier($\"\u002Fsubscriptions\u002F{subscriptionId}\"));\n```\n\n## Resource Hierarchy\n\n```\nArmClient\n└── SubscriptionResource\n    ├── PlaywrightQuotaResource (subscription-level quotas)\n    └── ResourceGroupResource\n        └── PlaywrightWorkspaceResource\n            └── PlaywrightWorkspaceQuotaResource (workspace-level quotas)\n```\n\n## Core Workflow\n\n### 1. Create Playwright Workspace\n\n```csharp\nusing Azure.ResourceManager.Playwright;\nusing Azure.ResourceManager.Playwright.Models;\n\n\u002F\u002F Get resource group\nvar resourceGroup = await subscription\n    .GetResourceGroupAsync(\"my-resource-group\");\n\n\u002F\u002F Define workspace\nvar workspaceData = new PlaywrightWorkspaceData(AzureLocation.WestUS3)\n{\n    \u002F\u002F Optional: Configure regional affinity and local auth\n    RegionalAffinity = PlaywrightRegionalAffinity.Enabled,\n    LocalAuth = PlaywrightLocalAuth.Enabled,\n    Tags =\n    {\n        [\"Team\"] = \"Dev Exp\",\n        [\"Environment\"] = \"Production\"\n    }\n};\n\n\u002F\u002F Create workspace (long-running operation)\nvar workspaceCollection = resourceGroup.Value.GetPlaywrightWorkspaces();\nvar operation = await workspaceCollection.CreateOrUpdateAsync(\n    WaitUntil.Completed,\n    \"my-playwright-workspace\",\n    workspaceData);\n\nPlaywrightWorkspaceResource workspace = operation.Value;\n\n\u002F\u002F Get the data plane URI for running tests\nConsole.WriteLine($\"Data Plane URI: {workspace.Data.DataplaneUri}\");\nConsole.WriteLine($\"Workspace ID: {workspace.Data.WorkspaceId}\");\n```\n\n### 2. Get Existing Workspace\n\n```csharp\n\u002F\u002F Get by name\nvar workspace = await workspaceCollection.GetAsync(\"my-playwright-workspace\");\n\n\u002F\u002F Or check if exists first\nbool exists = await workspaceCollection.ExistsAsync(\"my-playwright-workspace\");\nif (exists)\n{\n    var existingWorkspace = await workspaceCollection.GetAsync(\"my-playwright-workspace\");\n    Console.WriteLine($\"Workspace found: {existingWorkspace.Value.Data.Name}\");\n}\n```\n\n### 3. List Workspaces\n\n```csharp\n\u002F\u002F List in resource group\nawait foreach (var workspace in workspaceCollection.GetAllAsync())\n{\n    Console.WriteLine($\"Workspace: {workspace.Data.Name}\");\n    Console.WriteLine($\"  Location: {workspace.Data.Location}\");\n    Console.WriteLine($\"  State: {workspace.Data.ProvisioningState}\");\n    Console.WriteLine($\"  Data Plane URI: {workspace.Data.DataplaneUri}\");\n}\n\n\u002F\u002F List across subscription\nawait foreach (var workspace in subscription.GetPlaywrightWorkspacesAsync())\n{\n    Console.WriteLine($\"Workspace: {workspace.Data.Name}\");\n}\n```\n\n### 4. Update Workspace\n\n```csharp\nvar patch = new PlaywrightWorkspacePatch\n{\n    Tags =\n    {\n        [\"Team\"] = \"Dev Exp\",\n        [\"Environment\"] = \"Staging\",\n        [\"UpdatedAt\"] = DateTime.UtcNow.ToString(\"o\")\n    }\n};\n\nvar updatedWorkspace = await workspace.Value.UpdateAsync(patch);\n```\n\n### 5. Check Name Availability\n\n```csharp\nusing Azure.ResourceManager.Playwright.Models;\n\nvar checkRequest = new PlaywrightCheckNameAvailabilityContent\n{\n    Name = \"my-new-workspace\",\n    ResourceType = \"Microsoft.LoadTestService\u002FplaywrightWorkspaces\"\n};\n\nvar result = await subscription.CheckPlaywrightNameAvailabilityAsync(checkRequest);\n\nif (result.Value.IsNameAvailable == true)\n{\n    Console.WriteLine(\"Name is available!\");\n}\nelse\n{\n    Console.WriteLine($\"Name unavailable: {result.Value.Message}\");\n    Console.WriteLine($\"Reason: {result.Value.Reason}\");\n}\n```\n\n### 6. Get Quota Information\n\n```csharp\n\u002F\u002F Subscription-level quotas\nawait foreach (var quota in subscription.GetPlaywrightQuotasAsync(AzureLocation.WestUS3))\n{\n    Console.WriteLine($\"Quota: {quota.Data.Name}\");\n    Console.WriteLine($\"  Limit: {quota.Data.Limit}\");\n    Console.WriteLine($\"  Used: {quota.Data.Used}\");\n}\n\n\u002F\u002F Workspace-level quotas\nvar workspaceQuotas = workspace.Value.GetAllPlaywrightWorkspaceQuota();\nawait foreach (var quota in workspaceQuotas.GetAllAsync())\n{\n    Console.WriteLine($\"Workspace Quota: {quota.Data.Name}\");\n}\n```\n\n### 7. Delete Workspace\n\n```csharp\n\u002F\u002F Delete (long-running operation)\nawait workspace.Value.DeleteAsync(WaitUntil.Completed);\n```\n\n## Key Types Reference\n\n| Type | Purpose |\n|------|---------|\n| `ArmClient` | Entry point for all ARM operations |\n| `PlaywrightWorkspaceResource` | Represents a Playwright Testing workspace |\n| `PlaywrightWorkspaceCollection` | Collection for workspace CRUD |\n| `PlaywrightWorkspaceData` | Workspace creation\u002Fresponse payload |\n| `PlaywrightWorkspacePatch` | Workspace update payload |\n| `PlaywrightQuotaResource` | Subscription-level quota information |\n| `PlaywrightWorkspaceQuotaResource` | Workspace-level quota information |\n| `PlaywrightExtensions` | Extension methods for ARM resources |\n| `PlaywrightCheckNameAvailabilityContent` | Name availability check request |\n\n## Workspace Properties\n\n| Property | Description |\n|----------|-------------|\n| `DataplaneUri` | URI for running tests (e.g., `https:\u002F\u002Fapi.dataplane.{guid}.domain.com`) |\n| `WorkspaceId` | Unique workspace identifier (GUID) |\n| `RegionalAffinity` | Enable\u002Fdisable regional affinity for test execution |\n| `LocalAuth` | Enable\u002Fdisable local authentication (access tokens) |\n| `ProvisioningState` | Current provisioning state (Succeeded, Failed, etc.) |\n\n## Best Practices\n\n1. **Use `WaitUntil.Completed`** for operations that must finish before proceeding\n2. **Use `WaitUntil.Started`** when you want to poll manually or run operations in parallel\n3. **Always use `DefaultAzureCredential`** — never hardcode keys\n4. **Handle `RequestFailedException`** for ARM API errors\n5. **Use `CreateOrUpdateAsync`** for idempotent operations\n6. **Navigate hierarchy** via `Get*` methods (e.g., `resourceGroup.GetPlaywrightWorkspaces()`)\n7. **Store the DataplaneUri** after workspace creation for test execution configuration\n\n## Error Handling\n\n```csharp\nusing Azure;\n\ntry\n{\n    var operation = await workspaceCollection.CreateOrUpdateAsync(\n        WaitUntil.Completed, workspaceName, workspaceData);\n}\ncatch (RequestFailedException ex) when (ex.Status == 409)\n{\n    Console.WriteLine(\"Workspace already exists\");\n}\ncatch (RequestFailedException ex) when (ex.Status == 400)\n{\n    Console.WriteLine($\"Bad request: {ex.Message}\");\n}\ncatch (RequestFailedException ex)\n{\n    Console.WriteLine($\"ARM Error: {ex.Status} - {ex.ErrorCode}: {ex.Message}\");\n}\n```\n\n## Integration with Test Execution\n\nAfter creating a workspace, use the `DataplaneUri` to configure your Playwright tests:\n\n```csharp\n\u002F\u002F 1. Create workspace (this SDK)\nvar workspace = await workspaceCollection.CreateOrUpdateAsync(\n    WaitUntil.Completed, \"my-workspace\", workspaceData);\n\n\u002F\u002F 2. Get the service URL\nvar serviceUrl = workspace.Value.Data.DataplaneUri;\n\n\u002F\u002F 3. Set environment variable for test execution\nEnvironment.SetEnvironmentVariable(\"PLAYWRIGHT_SERVICE_URL\", serviceUrl.ToString());\n\n\u002F\u002F 4. Run tests using Azure.Developer.MicrosoftPlaywrightTesting.NUnit\n\u002F\u002F (separate package for test execution)\n```\n\n## Related SDKs\n\n| SDK | Purpose | Install |\n|-----|---------|---------|\n| `Azure.ResourceManager.Playwright` | Management plane (this SDK) | `dotnet add package Azure.ResourceManager.Playwright` |\n| `Azure.Developer.MicrosoftPlaywrightTesting.NUnit` | Run NUnit Playwright tests at scale | `dotnet add package Azure.Developer.MicrosoftPlaywrightTesting.NUnit --prerelease` |\n| `Azure.Developer.Playwright` | Playwright client library | `dotnet add package Azure.Developer.Playwright` |\n\n## API Information\n\n- **Resource Provider**: `Microsoft.LoadTestService`\n- **Default API Version**: `2025-09-01`\n- **Resource Type**: `Microsoft.LoadTestService\u002FplaywrightWorkspaces`\n\n## Documentation Links\n\n- [Azure.ResourceManager.Playwright API Reference](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fapi\u002Fazure.resourcemanager.playwright)\n- [Microsoft Playwright Testing Overview](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fazure\u002Fplaywright-testing\u002Foverview-what-is-microsoft-playwright-testing)\n- [Quickstart: Run Playwright Tests at Scale](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fazure\u002Fplaywright-testing\u002Fquickstart-run-end-to-end-tests)\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,212,1569,"2026-05-16 13:07:26",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"DevOps","devops","mdi-cog-outline","CI\u002FCD、容器化、部署运维",3,162,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"9bd6d467-d51a-46df-8174-47c8367fe27e","1.0.0","azure-resource-manager-playwright-dotnet.zip",3239,"uploads\u002Fskills\u002F299eb04f-416f-482d-952e-a5174ce8062e\u002Fazure-resource-manager-playwright-dotnet.zip","3f11fe97cb396cc7dec5ddb0491fe266ac70930e231708cb59fc6c3e960f9744","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":9864}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]