SharedPrivateLink IOperationSource <SharedPrivateLink> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = SharedPrivateLinkData.DeserializeSharedPrivateLinkData(document.RootElement);

            return(new SharedPrivateLink(_armClient, data));
        }
 internal static SharedPrivateLinkResourceList DeserializeSharedPrivateLinkResourceList(JsonElement element)
 {
     Optional<IReadOnlyList<SharedPrivateLinkData>> value = default;
     Optional<string> nextLink = default;
     foreach (var property in element.EnumerateObject())
     {
         if (property.NameEquals("value"))
         {
             if (property.Value.ValueKind == JsonValueKind.Null)
             {
                 property.ThrowNonNullablePropertyIsNull();
                 continue;
             }
             List<SharedPrivateLinkData> array = new List<SharedPrivateLinkData>();
             foreach (var item in property.Value.EnumerateArray())
             {
                 array.Add(SharedPrivateLinkData.DeserializeSharedPrivateLinkData(item));
             }
             value = array;
             continue;
         }
         if (property.NameEquals("nextLink"))
         {
             nextLink = property.Value.GetString();
             continue;
         }
     }
     return new SharedPrivateLinkResourceList(Optional.ToList(value), nextLink.Value);
 }
        public async Task <SharedPrivateLink> CreateSharedPrivateLink(string LinkName)
        {
            //1. create vnet
            var vnetData = new VirtualNetworkData()
            {
                Location     = "westus2",
                AddressSpace = new AddressSpace()
                {
                    AddressPrefixes = { "10.10.0.0/16", }
                },
                Subnets =
                {
                    new SubnetData()
                    {
                        Name = "subnet01", AddressPrefix = "10.10.1.0/24",
                    },
                    new SubnetData()
                    {
                        Name = "subnet02", AddressPrefix = "10.10.2.0/24", PrivateEndpointNetworkPolicies = "Disabled",
                    }
                },
            };
            var vnetContainer = _resourceGroup.GetVirtualNetworks();
            var vnet          = await vnetContainer.CreateOrUpdateAsync(true, _vnetName, vnetData);

            //2.1 Create AppServicePlan
            //string appServicePlanName = "appServicePlan5952";
            //string location = "westus2";
            //string appServicePlanId = $"{_resourceGroupIdentifier}/providers/Microsoft.Web/serverfarms/{appServicePlanName}";
            //var armClient = GetArmClient();
            //await armClient.DefaultSubscription.GetGenericResources().CreateOrUpdateAsync(appServicePlanId, new GenericResourceData(location)
            //{
            //    Properties = new Dictionary<string, object>
            //    {
            //        { "resources", new Dictionary<string, object>
            //            {
            //                { "type", "Microsoft.Web/serverfarms" },
            //                { "apiVersion", "2021-01-15" },
            //                { "name", appServicePlanName },
            //                { "location", location },
            //                { "kind", "app" },
            //                { "sku", new Dictionary<string,object>
            //                    {
            //                        { "name", "P1v2" },
            //                        { "tier", "PremiumV2" },
            //                        { "size", "P1v2" },
            //                        { "family", "P1v2" },
            //                        { "capacity", 1 },
            //                    }
            //                },
            //                { "properties", new Dictionary<string,object>
            //                    {
            //                        { "perSiteScaling", false },
            //                        { "elasticScaleEnabled", false },
            //                        { "maximumElasticWorkerCount", 1 },
            //                        { "isSpot", false },
            //                        { "reserved", false },
            //                        { "isXenon", false },
            //                        { "hyperV", false },
            //                        { "targetWorkerCount", 0 },
            //                        { "targetWorkerSizeId", 0 },
            //                    }
            //                },
            //            }
            //        }
            //    }
            //});

            //TODO: 2.2 Create Appservice(Microsoft.Web/sites)
            string WebAppName = SessionRecording.GenerateAssetName("site-");

            //3 create SharedPrivateLink
            //TODO: Creating a SharedPrivateLink inevitably requires manual approval on the portal.
            var container = _webPubSub.GetSharedPrivateLinks();
            SharedPrivateLinkData data = new SharedPrivateLinkData()
            {
                PrivateLinkResourceId = $"{_resourceGroupIdentifier}/providers/Microsoft.Web/sites/{WebAppName}/sharedPrivateLinkResources/{LinkName}",
                GroupId        = "webPubSub",
                RequestMessage = "please approve",
            };
            var link = await container.CreateOrUpdateAsync(true, LinkName, data);

            return(link.Value);
        }