From 4046e47522d700493b872e786abef660cc9235d7 Mon Sep 17 00:00:00 2001 From: Liangying Wei Date: Tue, 23 Apr 2024 17:09:35 +0800 Subject: [PATCH 1/5] Add WebPubSub provisioning --- eng/Packages.Data.props | 3 +- .../Azure.Provisioning.WebPubSub/CHANGELOG.md | 7 ++ .../Azure.Provisioning.WebPubSub/README.md | 81 +++++++++++++++++++ .../Azure.Provisioning.WebPubSub/assets.json | 6 ++ .../src/Azure.Provisioning.WebPubSub.csproj | 14 ++++ .../src/Properties/AssemblyInfo.cs | 6 ++ .../src/WebPubSubHub.cs | 66 +++++++++++++++ .../src/WebPubSubService.cs | 72 +++++++++++++++++ .../Azure.Provisioning.WebPubSub.Tests.csproj | 9 +++ .../ExistingWebPubSubResources/main.bicep | 15 ++++ .../rg_TEST_module/rg_TEST_module.bicep | 8 ++ .../tests/Infrastructure/WebPubSub/main.bicep | 40 +++++++++ .../WebPubSubResources/main.bicep | 38 +++++++++ .../tests/WebPubSubTests.cs | 46 +++++++++++ sdk/provisioning/Azure.Provisioning.sln | 12 +++ .../Azure.Provisioning/src/RoleDefinition.cs | 5 ++ 16 files changed, 427 insertions(+), 1 deletion(-) create mode 100644 sdk/provisioning/Azure.Provisioning.WebPubSub/CHANGELOG.md create mode 100644 sdk/provisioning/Azure.Provisioning.WebPubSub/README.md create mode 100644 sdk/provisioning/Azure.Provisioning.WebPubSub/assets.json create mode 100644 sdk/provisioning/Azure.Provisioning.WebPubSub/src/Azure.Provisioning.WebPubSub.csproj create mode 100644 sdk/provisioning/Azure.Provisioning.WebPubSub/src/Properties/AssemblyInfo.cs create mode 100644 sdk/provisioning/Azure.Provisioning.WebPubSub/src/WebPubSubHub.cs create mode 100644 sdk/provisioning/Azure.Provisioning.WebPubSub/src/WebPubSubService.cs create mode 100644 sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Azure.Provisioning.WebPubSub.Tests.csproj create mode 100644 sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/ExistingWebPubSubResources/main.bicep create mode 100644 sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/ExistingWebPubSubResources/resources/rg_TEST_module/rg_TEST_module.bicep create mode 100644 sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/WebPubSub/main.bicep create mode 100644 sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/WebPubSubResources/main.bicep create mode 100644 sdk/provisioning/Azure.Provisioning.WebPubSub/tests/WebPubSubTests.cs diff --git a/eng/Packages.Data.props b/eng/Packages.Data.props index 0ee99a3bd996..46ea82014711 100644 --- a/eng/Packages.Data.props +++ b/eng/Packages.Data.props @@ -144,7 +144,8 @@ - + + diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/CHANGELOG.md b/sdk/provisioning/Azure.Provisioning.WebPubSub/CHANGELOG.md new file mode 100644 index 000000000000..5e930b90fed5 --- /dev/null +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release History + +## 0.1.0-beta.1 (2024-04-28) + +### Features Added + +- Initial beta release of Azure.Provisioning.WebPubSub. diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/README.md b/sdk/provisioning/Azure.Provisioning.WebPubSub/README.md new file mode 100644 index 000000000000..82ecddd89acb --- /dev/null +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/README.md @@ -0,0 +1,81 @@ +# Azure Provisioning client library for .NET + +Azure.Provisioning.WebPubSub simplifies declarative resource provisioning in .NET for Azure Web PubSub. + +## Getting started + +### Install the package + +Install the client library for .NET with [NuGet](https://www.nuget.org/ ): + +```dotnetcli +dotnet add package Azure.Provisioning.ApplicationInsights --prerelease +``` + +### Prerequisites + +> You must have an [Azure subscription](https://azure.microsoft.com/free/dotnet/). + +### Authenticate the Client + +## Key concepts + +This library allows you to specify your infrastructure in a declarative style using dotnet. You can then use azd to deploy your infrastructure to Azure diretly without needing to write or maintain bicep or arm templates. + +## Examples + +Here is a simple example which creates a KeyVault. + +First create your Infrastructure class. + +```C# Snippet:SampleInfrastructure +public class SampleInfrastructure : Infrastructure +{ +} +``` + +Next add your resources into your infrastructure and then Build. + +```C# Snippet:KeyVaultOnly +// Create a new infrastructure +var infrastructure = new SampleInfrastructure(); + +// Add a new key vault +var keyVault = infrastructure.AddKeyVault(); + +// You can call Build to convert the infrastructure into bicep files +infrastructure.Build(); +``` + +## Troubleshooting + +- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues). +- Check [previous questions](https://stackoverflow.com/questions/tagged/azure+.net) or ask new ones on Stack Overflow using Azure and .NET tags. + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing +guide][cg]. + +This project welcomes contributions and suggestions. Most contributions +require you to agree to a Contributor License Agreement (CLA) declaring +that you have the right to, and actually do, grant us the rights to use +your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine +whether you need to provide a CLA and decorate the PR appropriately +(for example, label, comment). Follow the instructions provided by the +bot. You'll only need to do this action once across all repositories +using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For +more information, see the [Code of Conduct FAQ][coc_faq] or contact + with any other questions or comments. + + +[cg]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resourcemanager/Azure.ResourceManager/docs/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ + diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/assets.json b/sdk/provisioning/Azure.Provisioning.WebPubSub/assets.json new file mode 100644 index 000000000000..cc7594f9d89b --- /dev/null +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/assets.json @@ -0,0 +1,6 @@ +{ + "AssetsRepo": "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath": "net", + "TagPrefix": "net/provisioning/Azure.Provisioning.WebPubSub", + "Tag": "" +} \ No newline at end of file diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/src/Azure.Provisioning.WebPubSub.csproj b/sdk/provisioning/Azure.Provisioning.WebPubSub/src/Azure.Provisioning.WebPubSub.csproj new file mode 100644 index 000000000000..29b011d81e12 --- /dev/null +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/src/Azure.Provisioning.WebPubSub.csproj @@ -0,0 +1,14 @@ + + + + Azure.Provisioning.WebPubSub simplifies declarative resource provisioning in .NET for Azure Web PubSub. + 0.1.0-beta.1 + $(RequiredTargetFrameworks) + $(NoWarn);AZC0001 + + + + + + + diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/src/Properties/AssemblyInfo.cs b/sdk/provisioning/Azure.Provisioning.WebPubSub/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..15a940a47a16 --- /dev/null +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/src/Properties/AssemblyInfo.cs @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Diagnostics.CodeAnalysis; + +[assembly: Experimental("AZPROVISION001")] diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/src/WebPubSubHub.cs b/sdk/provisioning/Azure.Provisioning.WebPubSub/src/WebPubSubHub.cs new file mode 100644 index 000000000000..3e21fcb533e9 --- /dev/null +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/src/WebPubSubHub.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Azure.ResourceManager.WebPubSub; +using Azure.ResourceManager.WebPubSub.Models; + +namespace Azure.Provisioning.WebPubSub +{ + /// + /// Represents a hub setting for WebPubSub. + /// + public class WebPubSubHub : Resource + { + // https://learn.microsoft.com/azure/templates/microsoft.signalrservice/2023-02-01/webPubSub/hubs?pivots=deployment-language-bicep + private const string ResourceTypeName = "Microsoft.SignalRService/webPubSub/hubs"; + + private static WebPubSubHubData Empty(string name) => ArmWebPubSubModelFactory.WebPubSubHubData(); + + /// + /// Creates a new instance of the class. + /// + /// The scope. + /// The properties of the hub settings. + /// The parent. + /// The name. + /// The version. + public WebPubSubHub(IConstruct scope, + WebPubSubHubProperties properties, + WebPubSubService? parent = null, + string name = "Hub", + string version = WebPubSubService.DefaultVersion) + : this(scope, parent, name, version, false, (name) => ArmWebPubSubModelFactory.WebPubSubHubData( + name: name, + properties: properties)) + { + } + + private WebPubSubHub( + IConstruct scope, + WebPubSubService? parent, + string name, + string version = WebPubSubService.DefaultVersion, + bool isExisting = false, + Func? creator = null) + : base(scope, parent, name, ResourceTypeName, version, creator ?? Empty, isExisting) + { + } + + /// + /// Creates a new instance of the class referencing an existing instance. + /// + /// The scope. + /// The resource name. + /// The resource group. + /// The WebPubSub service instance. + public static WebPubSubHub FromExisting(IConstruct scope, string name, WebPubSubService? parent = null) + => new WebPubSubHub(scope, parent: parent, name: name, isExisting: true); + + /// + protected override Resource? FindParentInScope(IConstruct scope) + { + return scope.GetSingleResource() ?? new WebPubSubService(scope); + } + } +} diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/src/WebPubSubService.cs b/sdk/provisioning/Azure.Provisioning.WebPubSub/src/WebPubSubService.cs new file mode 100644 index 000000000000..78c07602a7c1 --- /dev/null +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/src/WebPubSubService.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Azure.Core; +using Azure.Provisioning.ResourceManager; +using Azure.ResourceManager.WebPubSub; +using Azure.ResourceManager.WebPubSub.Models; + +namespace Azure.Provisioning.WebPubSub +{ + /// + /// Represents a WebPubSub. + /// + public class WebPubSubService : Resource + { + // https://learn.microsoft.com/azure/templates/microsoft.signalrservice/2023-02-01/webPubSub?pivots=deployment-language-bicep + private const string ResourceTypeName = "Microsoft.SignalRService/webPubSub"; + // https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/webpubsub/Azure.ResourceManager.WebPubSub/src/Generated/RestOperations/WebPubSubRestOperations.cs#L36 + internal const string DefaultVersion = "2021-10-01"; + + private static WebPubSubData Empty(string name) => ArmWebPubSubModelFactory.WebPubSubData(); + + /// + /// Creates a new instance of the class. + /// + /// The scope. + /// The SKU. + /// The parent. + /// The name. + /// The version. + /// The location. + public WebPubSubService( + IConstruct scope, + BillingInfoSku? sku = default, + ResourceGroup? parent = default, + string name = "WebPubSub", + string version = DefaultVersion, + AzureLocation? location = default) + : this(scope, parent, name, version, false, (name) => ArmWebPubSubModelFactory.WebPubSubData( + name: name, + location: location ?? Environment.GetEnvironmentVariable("AZURE_LOCATION") ?? AzureLocation.WestUS, + sku: sku ?? new BillingInfoSku("Free_F1") { Capacity = 1 })) + { + AssignProperty(data => data.Name, GetAzureName(scope, name)); + } + + private WebPubSubService( + IConstruct scope, + ResourceGroup? parent, + string name, + string version = DefaultVersion, + bool isExisting = false, + Func? creator = null) + : base(scope, parent, name, ResourceTypeName, version, creator ?? Empty, isExisting) + { + } + + /// + /// Creates a new instance of the class referencing an existing instance. + /// + /// The scope. + /// The resource name. + /// The resource group. + /// The WebPubSub service instance. + public static WebPubSubService FromExisting(IConstruct scope, string name, ResourceGroup? parent = null) + => new WebPubSubService(scope, parent: parent, name: name, isExisting: true); + + /// + protected override string GetAzureName(IConstruct scope, string resourceName) => GetGloballyUniqueName(resourceName); + } +} diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Azure.Provisioning.WebPubSub.Tests.csproj b/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Azure.Provisioning.WebPubSub.Tests.csproj new file mode 100644 index 000000000000..b4677b92e932 --- /dev/null +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Azure.Provisioning.WebPubSub.Tests.csproj @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/ExistingWebPubSubResources/main.bicep b/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/ExistingWebPubSubResources/main.bicep new file mode 100644 index 000000000000..136bc7020567 --- /dev/null +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/ExistingWebPubSubResources/main.bicep @@ -0,0 +1,15 @@ +targetScope = 'subscription' + + +resource resourceGroup_I6QNkoPsb 'Microsoft.Resources/resourceGroups@2023-07-01' = { + name: 'rg-TEST' + location: 'westus' + tags: { + 'azd-env-name': 'TEST' + } +} + +module rg_TEST_module './resources/rg_TEST_module/rg_TEST_module.bicep' = { + name: 'rg_TEST_module' + scope: resourceGroup_I6QNkoPsb +} diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/ExistingWebPubSubResources/resources/rg_TEST_module/rg_TEST_module.bicep b/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/ExistingWebPubSubResources/resources/rg_TEST_module/rg_TEST_module.bicep new file mode 100644 index 000000000000..6e94949b34a8 --- /dev/null +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/ExistingWebPubSubResources/resources/rg_TEST_module/rg_TEST_module.bicep @@ -0,0 +1,8 @@ + +resource webPubSub_d95Jnanqk 'Microsoft.SignalRService/webPubSub@2021-10-01' existing = { + name: 'existingWebPubSub' +} + +resource webPubSubHub_da5Jnanqk 'Microsoft.SignalRService/webPubSub/hubs@2021-10-01' existing = { + name: '${webPubSub_d95Jnanqk}/existingWebPubSubHub' +} diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/WebPubSub/main.bicep b/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/WebPubSub/main.bicep new file mode 100644 index 000000000000..0970fc05315a --- /dev/null +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/WebPubSub/main.bicep @@ -0,0 +1,40 @@ +targetScope = 'resourceGroup' + +@description('') +param location string = resourceGroup().location + + +resource webPubSubService_ODEiZdnLK 'Microsoft.SignalRService/webPubSub@2021-10-01' = { + name: toLower(take('WebPubSub${uniqueString(resourceGroup().id)}', 24)) + location: location + sku: { + name: 'Standard_S1' + } + properties: { + } +} + +resource roleAssignment_Jjm5975dM 'Microsoft.Authorization/roleAssignments@2022-04-01' = { + scope: webPubSubService_ODEiZdnLK + name: guid(webPubSubService_ODEiZdnLK.id, '00000000-0000-0000-0000-000000000000', subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '12cf5a90-567b-43ae-8102-96cf46c7d9b4')) + properties: { + roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '12cf5a90-567b-43ae-8102-96cf46c7d9b4') + principalId: '00000000-0000-0000-0000-000000000000' + principalType: 'ServicePrincipal' + } +} + +resource webPubSubHub_0m6lmClrJ 'Microsoft.SignalRService/webPubSub/hubs@2021-10-01' = { + parent: webPubSubService_ODEiZdnLK + name: 'Hub' + properties: { + eventHandlers: [ + { + urlTemplate: 'tunnel:///eventhandler' + userEventPattern: '*' + } + ] + } +} + +output hostName string = webPubSubService_ODEiZdnLK.properties.hostName diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/WebPubSubResources/main.bicep b/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/WebPubSubResources/main.bicep new file mode 100644 index 000000000000..a098516a8380 --- /dev/null +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/WebPubSubResources/main.bicep @@ -0,0 +1,38 @@ +targetScope = 'resourceGroup' + +@description('') +param location string = resourceGroup().location + + +resource signalRService_TvD5y8AYq 'Microsoft.SignalRService/signalR@2022-02-01' = { + name: toLower(take('signalr${uniqueString(resourceGroup().id)}', 24)) + location: location + sku: { + name: 'Standard_S1' + } + properties: { + features: [ + { + flag: 'ServiceMode' + value: 'Serverless' + } + ] + cors: { + allowedOrigins: [ + '*' + ] + } + } +} + +resource roleAssignment_hFSNN5tl8 'Microsoft.Authorization/roleAssignments@2022-04-01' = { + scope: signalRService_TvD5y8AYq + name: guid(signalRService_TvD5y8AYq.id, '00000000-0000-0000-0000-000000000000', subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '420fcaa2-552c-430f-98ca-3264be4806c7')) + properties: { + roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '420fcaa2-552c-430f-98ca-3264be4806c7') + principalId: '00000000-0000-0000-0000-000000000000' + principalType: 'ServicePrincipal' + } +} + +output hostName string = signalRService_TvD5y8AYq.properties.hostName diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/WebPubSubTests.cs b/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/WebPubSubTests.cs new file mode 100644 index 000000000000..26d2ecf82e1a --- /dev/null +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/WebPubSubTests.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Threading.Tasks; +using Azure.Core.TestFramework; +using Azure.Provisioning.ResourceManager; +using Azure.Provisioning.Tests; +using Azure.ResourceManager.WebPubSub.Models; + +namespace Azure.Provisioning.WebPubSub.Tests +{ + public class WebPubSubTests : ProvisioningTestBase + { + public WebPubSubTests(bool isAsync) : base(isAsync) + { + } + + [RecordedTest] + public async Task WebPubSub() + { + TestInfrastructure infrastructure = new TestInfrastructure(configuration: new Configuration { UseInteractiveMode = true }); + var wps = new WebPubSubService(infrastructure, sku: new BillingInfoSku("Standard_S1")); + wps.AssignRole(RoleDefinition.WebPubSubServiceOwner, Guid.Empty); + var properties = new WebPubSubHubProperties(); + properties.EventHandlers.Add(new WebPubSubEventHandler("tunnel:///eventhandler") { UserEventPattern = "*" }); + _ = new WebPubSubHub(infrastructure, properties, parent: wps); + wps.AddOutput("hostName", data => data.HostName); + infrastructure.Build(GetOutputPath()); + + await ValidateBicepAsync(interactiveMode: true); + } + + [RecordedTest] + public async Task ExistingWebPubSubResources() + { + var infra = new TestInfrastructure(); + var rg = infra.AddResourceGroup(); + infra.AddResource(WebPubSubService.FromExisting(infra, "'existingWebPubSub'", rg)); + + infra.Build(GetOutputPath()); + + await ValidateBicepAsync(); + } + } +} diff --git a/sdk/provisioning/Azure.Provisioning.sln b/sdk/provisioning/Azure.Provisioning.sln index 5f5bec3b89c9..e4411b0114a9 100644 --- a/sdk/provisioning/Azure.Provisioning.sln +++ b/sdk/provisioning/Azure.Provisioning.sln @@ -69,6 +69,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Provisioning.Storage. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Core.TestFramework", "..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{C2778320-ADC6-4EEE-A1D8-98590CD1223D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Provisioning.WebPubSub", "Azure.Provisioning.WebPubSub\src\Azure.Provisioning.WebPubSub.csproj", "{1ABD7C57-D9A1-4CB5-BE6F-9E9F02E2886D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Provisioning.WebPubSub.Tests", "Azure.Provisioning.WebPubSub\tests\Azure.Provisioning.WebPubSub.Tests.csproj", "{AF6AAD6F-FD2D-4480-8194-0CB5E0083065}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -207,6 +211,14 @@ Global {C2778320-ADC6-4EEE-A1D8-98590CD1223D}.Debug|Any CPU.Build.0 = Debug|Any CPU {C2778320-ADC6-4EEE-A1D8-98590CD1223D}.Release|Any CPU.ActiveCfg = Release|Any CPU {C2778320-ADC6-4EEE-A1D8-98590CD1223D}.Release|Any CPU.Build.0 = Release|Any CPU + {1ABD7C57-D9A1-4CB5-BE6F-9E9F02E2886D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1ABD7C57-D9A1-4CB5-BE6F-9E9F02E2886D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1ABD7C57-D9A1-4CB5-BE6F-9E9F02E2886D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1ABD7C57-D9A1-4CB5-BE6F-9E9F02E2886D}.Release|Any CPU.Build.0 = Release|Any CPU + {AF6AAD6F-FD2D-4480-8194-0CB5E0083065}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF6AAD6F-FD2D-4480-8194-0CB5E0083065}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF6AAD6F-FD2D-4480-8194-0CB5E0083065}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF6AAD6F-FD2D-4480-8194-0CB5E0083065}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/sdk/provisioning/Azure.Provisioning/src/RoleDefinition.cs b/sdk/provisioning/Azure.Provisioning/src/RoleDefinition.cs index c9340f50c3cd..5bfc7e38bc8c 100644 --- a/sdk/provisioning/Azure.Provisioning/src/RoleDefinition.cs +++ b/sdk/provisioning/Azure.Provisioning/src/RoleDefinition.cs @@ -73,6 +73,11 @@ public RoleDefinition(string value) /// public static RoleDefinition SignalRAppServer { get; } = new RoleDefinition("420fcaa2-552c-430f-98ca-3264be4806c7"); + /// + /// Web PubSub Service Owner - Full access to Azure Web PubSub Service REST APIs + /// + public static RoleDefinition WebPubSubServiceOwner { get; } = new RoleDefinition("12cf5a90-567b-43ae-8102-96cf46c7d9b4"); + /// Converts a string to a . public static implicit operator RoleDefinition(string value) => new RoleDefinition(value); From 9ae23f43b90a2856c860e99449ed066327fde0a6 Mon Sep 17 00:00:00 2001 From: Liangying Wei Date: Tue, 23 Apr 2024 17:47:15 +0800 Subject: [PATCH 2/5] Add api --- ...Azure.Provisioning.WebPubSub.netstandard2.0.cs | 15 +++++++++++++++ .../api/Azure.Provisioning.net461.cs | 1 + .../api/Azure.Provisioning.net472.cs | 1 + .../api/Azure.Provisioning.net6.0.cs | 1 + .../api/Azure.Provisioning.netstandard2.0.cs | 1 + 5 files changed, 19 insertions(+) create mode 100644 sdk/provisioning/Azure.Provisioning.WebPubSub/api/Azure.Provisioning.WebPubSub.netstandard2.0.cs diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/api/Azure.Provisioning.WebPubSub.netstandard2.0.cs b/sdk/provisioning/Azure.Provisioning.WebPubSub/api/Azure.Provisioning.WebPubSub.netstandard2.0.cs new file mode 100644 index 000000000000..59054a89ba60 --- /dev/null +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/api/Azure.Provisioning.WebPubSub.netstandard2.0.cs @@ -0,0 +1,15 @@ +namespace Azure.Provisioning.WebPubSub +{ + public partial class WebPubSubHub : Azure.Provisioning.Resource + { + public WebPubSubHub(Azure.Provisioning.IConstruct scope, Azure.ResourceManager.WebPubSub.Models.WebPubSubHubProperties properties, Azure.Provisioning.WebPubSub.WebPubSubService? parent = null, string name = "Hub", string version = "2021-10-01") : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func), default(bool)) { } + protected override Azure.Provisioning.Resource? FindParentInScope(Azure.Provisioning.IConstruct scope) { throw null; } + public static Azure.Provisioning.WebPubSub.WebPubSubHub FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.WebPubSub.WebPubSubService? parent = null) { throw null; } + } + public partial class WebPubSubService : Azure.Provisioning.Resource + { + public WebPubSubService(Azure.Provisioning.IConstruct scope, Azure.ResourceManager.WebPubSub.Models.BillingInfoSku? sku = null, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, string name = "WebPubSub", string version = "2021-10-01", Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?)) : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func), default(bool)) { } + public static Azure.Provisioning.WebPubSub.WebPubSubService FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) { throw null; } + protected override string GetAzureName(Azure.Provisioning.IConstruct scope, string resourceName) { throw null; } + } +} diff --git a/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.net461.cs b/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.net461.cs index e06a089c1471..e33a88adf41c 100644 --- a/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.net461.cs +++ b/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.net461.cs @@ -145,6 +145,7 @@ public partial class RoleAssignment : Azure.Provisioning.Resource Date: Wed, 8 May 2024 13:34:01 +0800 Subject: [PATCH 3/5] Resolve comments --- sdk/provisioning/Azure.Provisioning.WebPubSub/CHANGELOG.md | 2 +- sdk/provisioning/Azure.Provisioning.WebPubSub/README.md | 2 +- .../Azure.Provisioning.WebPubSub/src/WebPubSubHub.cs | 2 +- .../Azure.Provisioning.WebPubSub/src/WebPubSubService.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/CHANGELOG.md b/sdk/provisioning/Azure.Provisioning.WebPubSub/CHANGELOG.md index 5e930b90fed5..75713709e7d2 100644 --- a/sdk/provisioning/Azure.Provisioning.WebPubSub/CHANGELOG.md +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 0.1.0-beta.1 (2024-04-28) +## 0.1.0-beta.1 (2024-05-10) ### Features Added diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/README.md b/sdk/provisioning/Azure.Provisioning.WebPubSub/README.md index 82ecddd89acb..6e5cd821d47c 100644 --- a/sdk/provisioning/Azure.Provisioning.WebPubSub/README.md +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/README.md @@ -9,7 +9,7 @@ Azure.Provisioning.WebPubSub simplifies declarative resource provisioning in .NE Install the client library for .NET with [NuGet](https://www.nuget.org/ ): ```dotnetcli -dotnet add package Azure.Provisioning.ApplicationInsights --prerelease +dotnet add package Azure.Provisioning.WebPubSub --prerelease ``` ### Prerequisites diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/src/WebPubSubHub.cs b/sdk/provisioning/Azure.Provisioning.WebPubSub/src/WebPubSubHub.cs index 3e21fcb533e9..1c8f39b67fd7 100644 --- a/sdk/provisioning/Azure.Provisioning.WebPubSub/src/WebPubSubHub.cs +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/src/WebPubSubHub.cs @@ -28,7 +28,7 @@ public class WebPubSubHub : Resource public WebPubSubHub(IConstruct scope, WebPubSubHubProperties properties, WebPubSubService? parent = null, - string name = "Hub", + string name = "hub", string version = WebPubSubService.DefaultVersion) : this(scope, parent, name, version, false, (name) => ArmWebPubSubModelFactory.WebPubSubHubData( name: name, diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/src/WebPubSubService.cs b/sdk/provisioning/Azure.Provisioning.WebPubSub/src/WebPubSubService.cs index 78c07602a7c1..98671498c9e3 100644 --- a/sdk/provisioning/Azure.Provisioning.WebPubSub/src/WebPubSubService.cs +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/src/WebPubSubService.cs @@ -34,7 +34,7 @@ public WebPubSubService( IConstruct scope, BillingInfoSku? sku = default, ResourceGroup? parent = default, - string name = "WebPubSub", + string name = "webpubsub", string version = DefaultVersion, AzureLocation? location = default) : this(scope, parent, name, version, false, (name) => ArmWebPubSubModelFactory.WebPubSubData( From 7368f92eafaa04900486d873ddcf28aed2b53e6a Mon Sep 17 00:00:00 2001 From: Liangying Wei Date: Fri, 10 May 2024 13:17:05 +0800 Subject: [PATCH 4/5] Fix build failure --- sdk/provisioning/Azure.Provisioning.WebPubSub/README.md | 5 ++++- .../api/Azure.Provisioning.WebPubSub.netstandard2.0.cs | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/README.md b/sdk/provisioning/Azure.Provisioning.WebPubSub/README.md index 6e5cd821d47c..438df373bb06 100644 --- a/sdk/provisioning/Azure.Provisioning.WebPubSub/README.md +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/README.md @@ -31,6 +31,9 @@ First create your Infrastructure class. ```C# Snippet:SampleInfrastructure public class SampleInfrastructure : Infrastructure { + public SampleInfrastructure() : base(envName: "Sample", tenantId: Guid.Empty, subscriptionId: Guid.Empty, configuration: new Configuration { UseInteractiveMode = true }) + { + } } ``` @@ -43,7 +46,7 @@ var infrastructure = new SampleInfrastructure(); // Add a new key vault var keyVault = infrastructure.AddKeyVault(); -// You can call Build to convert the infrastructure into bicep files +// You can call Build to convert the infrastructure into bicep files. infrastructure.Build(); ``` diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/api/Azure.Provisioning.WebPubSub.netstandard2.0.cs b/sdk/provisioning/Azure.Provisioning.WebPubSub/api/Azure.Provisioning.WebPubSub.netstandard2.0.cs index 59054a89ba60..b8af4abe56e9 100644 --- a/sdk/provisioning/Azure.Provisioning.WebPubSub/api/Azure.Provisioning.WebPubSub.netstandard2.0.cs +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/api/Azure.Provisioning.WebPubSub.netstandard2.0.cs @@ -2,13 +2,13 @@ namespace Azure.Provisioning.WebPubSub { public partial class WebPubSubHub : Azure.Provisioning.Resource { - public WebPubSubHub(Azure.Provisioning.IConstruct scope, Azure.ResourceManager.WebPubSub.Models.WebPubSubHubProperties properties, Azure.Provisioning.WebPubSub.WebPubSubService? parent = null, string name = "Hub", string version = "2021-10-01") : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func), default(bool)) { } + public WebPubSubHub(Azure.Provisioning.IConstruct scope, Azure.ResourceManager.WebPubSub.Models.WebPubSubHubProperties properties, Azure.Provisioning.WebPubSub.WebPubSubService? parent = null, string name = "hub", string version = "2021-10-01") : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func), default(bool)) { } protected override Azure.Provisioning.Resource? FindParentInScope(Azure.Provisioning.IConstruct scope) { throw null; } public static Azure.Provisioning.WebPubSub.WebPubSubHub FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.WebPubSub.WebPubSubService? parent = null) { throw null; } } public partial class WebPubSubService : Azure.Provisioning.Resource { - public WebPubSubService(Azure.Provisioning.IConstruct scope, Azure.ResourceManager.WebPubSub.Models.BillingInfoSku? sku = null, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, string name = "WebPubSub", string version = "2021-10-01", Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?)) : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func), default(bool)) { } + public WebPubSubService(Azure.Provisioning.IConstruct scope, Azure.ResourceManager.WebPubSub.Models.BillingInfoSku? sku = null, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, string name = "webpubsub", string version = "2021-10-01", Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?)) : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func), default(bool)) { } public static Azure.Provisioning.WebPubSub.WebPubSubService FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) { throw null; } protected override string GetAzureName(Azure.Provisioning.IConstruct scope, string resourceName) { throw null; } } From 0e7e8a089790efbf8f44fde9cb728e961eb0eb5f Mon Sep 17 00:00:00 2001 From: Liangying Wei Date: Sat, 11 May 2024 09:57:57 +0800 Subject: [PATCH 5/5] Fix tests --- .../Azure.Provisioning.WebPubSub/assets.json | 2 +- .../rg_TEST_module/rg_TEST_module.bicep | 6 +----- .../tests/Infrastructure/WebPubSub/main.bicep | 18 +++++++++--------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/assets.json b/sdk/provisioning/Azure.Provisioning.WebPubSub/assets.json index cc7594f9d89b..81f5b60480e2 100644 --- a/sdk/provisioning/Azure.Provisioning.WebPubSub/assets.json +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "net/provisioning/Azure.Provisioning.WebPubSub", - "Tag": "" + "Tag": "net/provisioning/Azure.Provisioning.WebPubSub_ee1c01a8d9" } \ No newline at end of file diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/ExistingWebPubSubResources/resources/rg_TEST_module/rg_TEST_module.bicep b/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/ExistingWebPubSubResources/resources/rg_TEST_module/rg_TEST_module.bicep index 6e94949b34a8..30e8a98512f1 100644 --- a/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/ExistingWebPubSubResources/resources/rg_TEST_module/rg_TEST_module.bicep +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/ExistingWebPubSubResources/resources/rg_TEST_module/rg_TEST_module.bicep @@ -1,8 +1,4 @@ -resource webPubSub_d95Jnanqk 'Microsoft.SignalRService/webPubSub@2021-10-01' existing = { +resource webPubSubService_f0nsipxGj 'Microsoft.SignalRService/webPubSub@2021-10-01' existing = { name: 'existingWebPubSub' } - -resource webPubSubHub_da5Jnanqk 'Microsoft.SignalRService/webPubSub/hubs@2021-10-01' existing = { - name: '${webPubSub_d95Jnanqk}/existingWebPubSubHub' -} diff --git a/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/WebPubSub/main.bicep b/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/WebPubSub/main.bicep index 0970fc05315a..a2a5554476ea 100644 --- a/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/WebPubSub/main.bicep +++ b/sdk/provisioning/Azure.Provisioning.WebPubSub/tests/Infrastructure/WebPubSub/main.bicep @@ -4,8 +4,8 @@ targetScope = 'resourceGroup' param location string = resourceGroup().location -resource webPubSubService_ODEiZdnLK 'Microsoft.SignalRService/webPubSub@2021-10-01' = { - name: toLower(take('WebPubSub${uniqueString(resourceGroup().id)}', 24)) +resource webPubSubService_EAdO6ICWi 'Microsoft.SignalRService/webPubSub@2021-10-01' = { + name: toLower(take('webpubsub${uniqueString(resourceGroup().id)}', 24)) location: location sku: { name: 'Standard_S1' @@ -14,9 +14,9 @@ resource webPubSubService_ODEiZdnLK 'Microsoft.SignalRService/webPubSub@2021-10- } } -resource roleAssignment_Jjm5975dM 'Microsoft.Authorization/roleAssignments@2022-04-01' = { - scope: webPubSubService_ODEiZdnLK - name: guid(webPubSubService_ODEiZdnLK.id, '00000000-0000-0000-0000-000000000000', subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '12cf5a90-567b-43ae-8102-96cf46c7d9b4')) +resource roleAssignment_eQVZzvRPP 'Microsoft.Authorization/roleAssignments@2022-04-01' = { + scope: webPubSubService_EAdO6ICWi + name: guid(webPubSubService_EAdO6ICWi.id, '00000000-0000-0000-0000-000000000000', subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '12cf5a90-567b-43ae-8102-96cf46c7d9b4')) properties: { roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '12cf5a90-567b-43ae-8102-96cf46c7d9b4') principalId: '00000000-0000-0000-0000-000000000000' @@ -24,9 +24,9 @@ resource roleAssignment_Jjm5975dM 'Microsoft.Authorization/roleAssignments@2022- } } -resource webPubSubHub_0m6lmClrJ 'Microsoft.SignalRService/webPubSub/hubs@2021-10-01' = { - parent: webPubSubService_ODEiZdnLK - name: 'Hub' +resource webPubSubHub_tKhq1vFqb 'Microsoft.SignalRService/webPubSub/hubs@2021-10-01' = { + parent: webPubSubService_EAdO6ICWi + name: 'hub' properties: { eventHandlers: [ { @@ -37,4 +37,4 @@ resource webPubSubHub_0m6lmClrJ 'Microsoft.SignalRService/webPubSub/hubs@2021-10 } } -output hostName string = webPubSubService_ODEiZdnLK.properties.hostName +output hostName string = webPubSubService_EAdO6ICWi.properties.hostName