|
Add this skill
npx mdskills install sickn33/azure-resource-manager-playwright-dotnetComprehensive Azure Resource Manager SDK documentation with clear workflow examples and proper scope distinction
1---2name: azure-resource-manager-playwright-dotnet3description: |4 Azure Resource Manager SDK for Microsoft Playwright Testing in .NET. Use for MANAGEMENT PLANE operations: creating/managing Playwright Testing workspaces, checking name availability, and managing workspace quotas via Azure Resource Manager. NOT for running Playwright tests - use Azure.Developer.MicrosoftPlaywrightTesting.NUnit for that. Triggers: "Playwright workspace", "create Playwright Testing workspace", "manage Playwright resources", "ARM Playwright", "PlaywrightWorkspaceResource", "provision Playwright Testing".5package: Azure.ResourceManager.Playwright6---78# Azure.ResourceManager.Playwright (.NET)910Management plane SDK for provisioning and managing Microsoft Playwright Testing workspaces via Azure Resource Manager.1112> **⚠️ Management vs Test Execution**13> - **This SDK (Azure.ResourceManager.Playwright)**: Create workspaces, manage quotas, check name availability14> - **Test Execution SDK (Azure.Developer.MicrosoftPlaywrightTesting.NUnit)**: Run Playwright tests at scale on cloud browsers1516## Installation1718```bash19dotnet add package Azure.ResourceManager.Playwright20dotnet add package Azure.Identity21```2223**Current Versions**: Stable v1.0.0, Preview v1.0.0-beta.12425## Environment Variables2627```bash28AZURE_SUBSCRIPTION_ID=<your-subscription-id>29# For service principal auth (optional)30AZURE_TENANT_ID=<tenant-id>31AZURE_CLIENT_ID=<client-id>32AZURE_CLIENT_SECRET=<client-secret>33```3435## Authentication3637```csharp38using Azure.Identity;39using Azure.ResourceManager;40using Azure.ResourceManager.Playwright;4142// Always use DefaultAzureCredential43var credential = new DefaultAzureCredential();44var armClient = new ArmClient(credential);4546// Get subscription47var subscriptionId = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID");48var subscription = armClient.GetSubscriptionResource(49 new ResourceIdentifier($"/subscriptions/{subscriptionId}"));50```5152## Resource Hierarchy5354```55ArmClient56└── SubscriptionResource57 ├── PlaywrightQuotaResource (subscription-level quotas)58 └── ResourceGroupResource59 └── PlaywrightWorkspaceResource60 └── PlaywrightWorkspaceQuotaResource (workspace-level quotas)61```6263## Core Workflow6465### 1. Create Playwright Workspace6667```csharp68using Azure.ResourceManager.Playwright;69using Azure.ResourceManager.Playwright.Models;7071// Get resource group72var resourceGroup = await subscription73 .GetResourceGroupAsync("my-resource-group");7475// Define workspace76var workspaceData = new PlaywrightWorkspaceData(AzureLocation.WestUS3)77{78 // Optional: Configure regional affinity and local auth79 RegionalAffinity = PlaywrightRegionalAffinity.Enabled,80 LocalAuth = PlaywrightLocalAuth.Enabled,81 Tags =82 {83 ["Team"] = "Dev Exp",84 ["Environment"] = "Production"85 }86};8788// Create workspace (long-running operation)89var workspaceCollection = resourceGroup.Value.GetPlaywrightWorkspaces();90var operation = await workspaceCollection.CreateOrUpdateAsync(91 WaitUntil.Completed,92 "my-playwright-workspace",93 workspaceData);9495PlaywrightWorkspaceResource workspace = operation.Value;9697// Get the data plane URI for running tests98Console.WriteLine($"Data Plane URI: {workspace.Data.DataplaneUri}");99Console.WriteLine($"Workspace ID: {workspace.Data.WorkspaceId}");100```101102### 2. Get Existing Workspace103104```csharp105// Get by name106var workspace = await workspaceCollection.GetAsync("my-playwright-workspace");107108// Or check if exists first109bool exists = await workspaceCollection.ExistsAsync("my-playwright-workspace");110if (exists)111{112 var existingWorkspace = await workspaceCollection.GetAsync("my-playwright-workspace");113 Console.WriteLine($"Workspace found: {existingWorkspace.Value.Data.Name}");114}115```116117### 3. List Workspaces118119```csharp120// List in resource group121await foreach (var workspace in workspaceCollection.GetAllAsync())122{123 Console.WriteLine($"Workspace: {workspace.Data.Name}");124 Console.WriteLine($" Location: {workspace.Data.Location}");125 Console.WriteLine($" State: {workspace.Data.ProvisioningState}");126 Console.WriteLine($" Data Plane URI: {workspace.Data.DataplaneUri}");127}128129// List across subscription130await foreach (var workspace in subscription.GetPlaywrightWorkspacesAsync())131{132 Console.WriteLine($"Workspace: {workspace.Data.Name}");133}134```135136### 4. Update Workspace137138```csharp139var patch = new PlaywrightWorkspacePatch140{141 Tags =142 {143 ["Team"] = "Dev Exp",144 ["Environment"] = "Staging",145 ["UpdatedAt"] = DateTime.UtcNow.ToString("o")146 }147};148149var updatedWorkspace = await workspace.Value.UpdateAsync(patch);150```151152### 5. Check Name Availability153154```csharp155using Azure.ResourceManager.Playwright.Models;156157var checkRequest = new PlaywrightCheckNameAvailabilityContent158{159 Name = "my-new-workspace",160 ResourceType = "Microsoft.LoadTestService/playwrightWorkspaces"161};162163var result = await subscription.CheckPlaywrightNameAvailabilityAsync(checkRequest);164165if (result.Value.IsNameAvailable == true)166{167 Console.WriteLine("Name is available!");168}169else170{171 Console.WriteLine($"Name unavailable: {result.Value.Message}");172 Console.WriteLine($"Reason: {result.Value.Reason}");173}174```175176### 6. Get Quota Information177178```csharp179// Subscription-level quotas180await foreach (var quota in subscription.GetPlaywrightQuotasAsync(AzureLocation.WestUS3))181{182 Console.WriteLine($"Quota: {quota.Data.Name}");183 Console.WriteLine($" Limit: {quota.Data.Limit}");184 Console.WriteLine($" Used: {quota.Data.Used}");185}186187// Workspace-level quotas188var workspaceQuotas = workspace.Value.GetAllPlaywrightWorkspaceQuota();189await foreach (var quota in workspaceQuotas.GetAllAsync())190{191 Console.WriteLine($"Workspace Quota: {quota.Data.Name}");192}193```194195### 7. Delete Workspace196197```csharp198// Delete (long-running operation)199await workspace.Value.DeleteAsync(WaitUntil.Completed);200```201202## Key Types Reference203204| Type | Purpose |205|------|---------|206| `ArmClient` | Entry point for all ARM operations |207| `PlaywrightWorkspaceResource` | Represents a Playwright Testing workspace |208| `PlaywrightWorkspaceCollection` | Collection for workspace CRUD |209| `PlaywrightWorkspaceData` | Workspace creation/response payload |210| `PlaywrightWorkspacePatch` | Workspace update payload |211| `PlaywrightQuotaResource` | Subscription-level quota information |212| `PlaywrightWorkspaceQuotaResource` | Workspace-level quota information |213| `PlaywrightExtensions` | Extension methods for ARM resources |214| `PlaywrightCheckNameAvailabilityContent` | Name availability check request |215216## Workspace Properties217218| Property | Description |219|----------|-------------|220| `DataplaneUri` | URI for running tests (e.g., `https://api.dataplane.{guid}.domain.com`) |221| `WorkspaceId` | Unique workspace identifier (GUID) |222| `RegionalAffinity` | Enable/disable regional affinity for test execution |223| `LocalAuth` | Enable/disable local authentication (access tokens) |224| `ProvisioningState` | Current provisioning state (Succeeded, Failed, etc.) |225226## Best Practices2272281. **Use `WaitUntil.Completed`** for operations that must finish before proceeding2292. **Use `WaitUntil.Started`** when you want to poll manually or run operations in parallel2303. **Always use `DefaultAzureCredential`** — never hardcode keys2314. **Handle `RequestFailedException`** for ARM API errors2325. **Use `CreateOrUpdateAsync`** for idempotent operations2336. **Navigate hierarchy** via `Get*` methods (e.g., `resourceGroup.GetPlaywrightWorkspaces()`)2347. **Store the DataplaneUri** after workspace creation for test execution configuration235236## Error Handling237238```csharp239using Azure;240241try242{243 var operation = await workspaceCollection.CreateOrUpdateAsync(244 WaitUntil.Completed, workspaceName, workspaceData);245}246catch (RequestFailedException ex) when (ex.Status == 409)247{248 Console.WriteLine("Workspace already exists");249}250catch (RequestFailedException ex) when (ex.Status == 400)251{252 Console.WriteLine($"Bad request: {ex.Message}");253}254catch (RequestFailedException ex)255{256 Console.WriteLine($"ARM Error: {ex.Status} - {ex.ErrorCode}: {ex.Message}");257}258```259260## Integration with Test Execution261262After creating a workspace, use the `DataplaneUri` to configure your Playwright tests:263264```csharp265// 1. Create workspace (this SDK)266var workspace = await workspaceCollection.CreateOrUpdateAsync(267 WaitUntil.Completed, "my-workspace", workspaceData);268269// 2. Get the service URL270var serviceUrl = workspace.Value.Data.DataplaneUri;271272// 3. Set environment variable for test execution273Environment.SetEnvironmentVariable("PLAYWRIGHT_SERVICE_URL", serviceUrl.ToString());274275// 4. Run tests using Azure.Developer.MicrosoftPlaywrightTesting.NUnit276// (separate package for test execution)277```278279## Related SDKs280281| SDK | Purpose | Install |282|-----|---------|---------|283| `Azure.ResourceManager.Playwright` | Management plane (this SDK) | `dotnet add package Azure.ResourceManager.Playwright` |284| `Azure.Developer.MicrosoftPlaywrightTesting.NUnit` | Run NUnit Playwright tests at scale | `dotnet add package Azure.Developer.MicrosoftPlaywrightTesting.NUnit --prerelease` |285| `Azure.Developer.Playwright` | Playwright client library | `dotnet add package Azure.Developer.Playwright` |286287## API Information288289- **Resource Provider**: `Microsoft.LoadTestService`290- **Default API Version**: `2025-09-01`291- **Resource Type**: `Microsoft.LoadTestService/playwrightWorkspaces`292293## Documentation Links294295- [Azure.ResourceManager.Playwright API Reference](https://learn.microsoft.com/en-us/dotnet/api/azure.resourcemanager.playwright)296- [Microsoft Playwright Testing Overview](https://learn.microsoft.com/en-us/azure/playwright-testing/overview-what-is-microsoft-playwright-testing)297- [Quickstart: Run Playwright Tests at Scale](https://learn.microsoft.com/en-us/azure/playwright-testing/quickstart-run-end-to-end-tests)298
Full transparency — inspect the skill content before installing.