internal static ConfigurationStoreListResult DeserializeConfigurationStoreListResult(JsonElement element)
        {
            Optional <IReadOnlyList <ConfigurationStoreData> > 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 <ConfigurationStoreData> array = new List <ConfigurationStoreData>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ConfigurationStoreData.DeserializeConfigurationStoreData(item));
                    }
                    value = array;
                    continue;
                }
                if (property.NameEquals("nextLink"))
                {
                    nextLink = property.Value.GetString();
                    continue;
                }
            }
            return(new ConfigurationStoreListResult(Optional.ToList(value), nextLink.Value));
        }
        ConfigurationStore IOperationSource <ConfigurationStore> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = ConfigurationStoreData.DeserializeConfigurationStoreData(document.RootElement);

            return(new ConfigurationStore(_armClient, data));
        }
        public async Task TestSetUp()
        {
            if (Mode == RecordedTestMode.Record || Mode == RecordedTestMode.Playback)
            {
                Initialize();
                string groupName    = Recording.GenerateAssetName(ResourceGroupPrefix);
                string VnetName     = Recording.GenerateAssetName("vnetname");
                string SubnetName   = Recording.GenerateAssetName("subnetname");
                string EndpointName = Recording.GenerateAssetName("endpointxyz");
                ResGroup = await(await ArmClient.GetDefaultSubscriptionAsync().Result.GetResourceGroups().CreateOrUpdateAsync(groupName, new ResourceGroupData(Location))).WaitForCompletionAsync();
                string configurationStoreName = Recording.GenerateAssetName("testapp-");
                ConfigurationStoreData configurationStoreData = new ConfigurationStoreData(Location, new Models.Sku("Standard"))
                {
                    PublicNetworkAccess = PublicNetworkAccess.Disabled
                };
                ConfigStore = await(await ResGroup.GetConfigurationStores().CreateOrUpdateAsync(configurationStoreName, configurationStoreData)).WaitForCompletionAsync();
                // Prepare VNet and Private Endpoint
                VirtualNetworkData vnetData = new VirtualNetworkData()
                {
                    Location     = "eastus",
                    AddressSpace = new AddressSpace()
                    {
                        AddressPrefixes = { "10.0.0.0/16", }
                    },
                    DhcpOptions = new DhcpOptions()
                    {
                        DnsServers = { "10.1.1.1", "10.1.2.4" }
                    },
                    Subnets = { new SubnetData()
                                {
                                    Name = SubnetName, AddressPrefix = "10.0.0.0/24", PrivateEndpointNetworkPolicies = "Disabled"
                                } }
                };
                VirtualNetwork      vnet = await(await ResGroup.GetVirtualNetworks().CreateOrUpdateAsync(VnetName, vnetData)).WaitForCompletionAsync();
                PrivateEndpointData privateEndpointData = new PrivateEndpointData()
                {
                    Location = "eastus",
                    PrivateLinkServiceConnections = { new PrivateLinkServiceConnection()
                                                      {
                                                          Name = "myconnection",
                                                          PrivateLinkServiceId = ConfigStore.Data.Id,
                                                          GroupIds             = { "configurationStores" },
                                                          RequestMessage       = "Please approve my connection",
                                                      } },
                    Subnet = new SubnetData()
                    {
                        Id = "/subscriptions/" + TestEnvironment.SubscriptionId + "/resourceGroups/" + groupName + "/providers/Microsoft.Network/virtualNetworks/" + VnetName + "/subnets/" + SubnetName
                    }
                };
                PrivateEndpoint = await(await ResGroup.GetPrivateEndpoints().CreateOrUpdateAsync(EndpointName, privateEndpointData)).WaitForCompletionAsync();
                List <PrivateEndpointConnection> connections = await ConfigStore.GetPrivateEndpointConnections().GetAllAsync().ToEnumerableAsync();

                Connection = connections.FirstOrDefault();
            }
        }
        public async Task CreateOrUpdate()
        {
            #region Snippet:Managing_ConfigurationStores_CreateAConfigurationStore
            string configurationStoreName = ("myApp");
            ConfigurationStoreData configurationStoreData = new ConfigurationStoreData("westus", new Models.Sku("Standard"))
            {
                PublicNetworkAccess = PublicNetworkAccess.Disabled
            };
            ConfigurationStore configurationStore = await(await resourceGroup.GetConfigurationStores().CreateOrUpdateAsync(configurationStoreName, configurationStoreData)).WaitForCompletionAsync();

            #endregion
        }
示例#5
0
        public async Task CreateOrUpdate()
        {
            #region Snippet:Managing_ConfigurationStores_CreateAConfigurationStore
            string configurationStoreName = ("myApp");
            ConfigurationStoreData configurationStoreData = new ConfigurationStoreData("westus", new AppConfigurationSku("Standard"))
            {
                PublicNetworkAccess = PublicNetworkAccess.Disabled
            };
            ConfigurationStoreResource configurationStore = (await resourceGroup.GetConfigurationStores().CreateOrUpdateAsync(WaitUntil.Completed, configurationStoreName, configurationStoreData)).Value;

            #endregion
        }
示例#6
0
        public async Task GetTest()
        {
            string configurationStoreName = Recording.GenerateAssetName("testapp-");
            ConfigurationStoreData configurationStoreData = new ConfigurationStoreData(Location, new Models.Sku("Standard"))
            {
                PublicNetworkAccess = PublicNetworkAccess.Disabled
            };

            await(await ResGroup.GetConfigurationStores().CreateOrUpdateAsync(configurationStoreName, configurationStoreData)).WaitForCompletionAsync();
            ConfigurationStore configurationStore = await ResGroup.GetConfigurationStores().GetAsync(configurationStoreName);

            Assert.IsTrue(configurationStoreName.Equals(configurationStore.Data.Name));
            Assert.IsTrue(configurationStore.Data.PublicNetworkAccess == PublicNetworkAccess.Disabled);
        }
 public async Task TestSetUp()
 {
     if (Mode == RecordedTestMode.Record || Mode == RecordedTestMode.Playback)
     {
         Initialize();
         string groupName = Recording.GenerateAssetName(ResourceGroupPrefix);
         ResGroup = (await ArmClient.GetDefaultSubscriptionAsync().Result.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, groupName, new ResourceGroupData(Location))).Value;
         string configurationStoreName = Recording.GenerateAssetName("testapp-");
         ConfigurationStoreData configurationStoreData = new ConfigurationStoreData(Location, new AppConfigurationSku("Standard"))
         {
             PublicNetworkAccess = PublicNetworkAccess.Disabled
         };
         ConfigStore = (await ResGroup.GetConfigurationStores().CreateOrUpdateAsync(WaitUntil.Completed, configurationStoreName, configurationStoreData)).Value;
     }
 }
示例#8
0
        public async Task GetAllTest()
        {
            string configurationStoreName1 = Recording.GenerateAssetName("testapp-");
            string configurationStoreName2 = Recording.GenerateAssetName("testapp-");
            ConfigurationStoreData configurationStoreData = new ConfigurationStoreData(Location, new Models.Sku("Standard"))
            {
                PublicNetworkAccess = PublicNetworkAccess.Disabled
            };

            await(await ResGroup.GetConfigurationStores().CreateOrUpdateAsync(configurationStoreName1, configurationStoreData)).WaitForCompletionAsync();
            await(await ResGroup.GetConfigurationStores().CreateOrUpdateAsync(configurationStoreName2, configurationStoreData)).WaitForCompletionAsync();
            List <ConfigurationStore> configurationStores = await ResGroup.GetConfigurationStores().GetAllAsync().ToEnumerableAsync();

            Assert.IsTrue(configurationStores.Count == 2);
            Assert.IsTrue(configurationStores.Where(x => x.Data.Name == configurationStoreName1).FirstOrDefault().Data.PublicNetworkAccess == PublicNetworkAccess.Disabled);
        }
 public async Task TestSetUp()
 {
     if (Mode == RecordedTestMode.Record || Mode == RecordedTestMode.Playback)
     {
         Initialize();
         string groupName = Recording.GenerateAssetName(ResourceGroupPrefix);
         ResGroup = await(await ArmClient.GetDefaultSubscriptionAsync().Result.GetResourceGroups().CreateOrUpdateAsync(groupName, new ResourceGroupData(Location))).WaitForCompletionAsync();
         string configurationStoreName = Recording.GenerateAssetName("testapp-");
         ConfigurationStoreData configurationStoreData = new ConfigurationStoreData(Location, new Models.Sku("Standard"))
         {
             PublicNetworkAccess = PublicNetworkAccess.Disabled
         };
         ConfigStore  = await(await ResGroup.GetConfigurationStores().CreateOrUpdateAsync(configurationStoreName, configurationStoreData)).WaitForCompletionAsync();
         LinkResource = await ConfigStore.GetPrivateLinkResources().GetAsync("configurationStores");
     }
 }
示例#10
0
 public async Task TestSetUp()
 {
     if (Mode == RecordedTestMode.Record || Mode == RecordedTestMode.Playback)
     {
         Initialize();
         string groupName    = Recording.GenerateAssetName(ResourceGroupPrefix);
         string VnetName     = Recording.GenerateAssetName("vnetname");
         string SubnetName   = Recording.GenerateAssetName("subnetname");
         string EndpointName = Recording.GenerateAssetName("endpointxyz");
         ResGroup = (await ArmClient.GetDefaultSubscriptionAsync().Result.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, groupName, new ResourceGroupData(Location))).Value;
         string configurationStoreName = Recording.GenerateAssetName("testapp-");
         ConfigurationStoreData configurationStoreData = new ConfigurationStoreData(Location, new AppConfigurationSku("Standard"))
         {
             PublicNetworkAccess = PublicNetworkAccess.Disabled
         };
         ConfigStore = (await ResGroup.GetConfigurationStores().CreateOrUpdateAsync(WaitUntil.Completed, configurationStoreName, configurationStoreData)).Value;
         // Prepare VNet and Private Endpoint
         VirtualNetworkData vnetData = new VirtualNetworkData()
         {
             Location = "eastus",
             Subnets  = { new SubnetData()
                          {
                              Name = SubnetName, AddressPrefix = "10.0.0.0/24", PrivateEndpointNetworkPolicies = "Disabled"
                          } }
         };
         vnetData.AddressPrefixes.Add("10.0.0.0/16");
         vnetData.DhcpOptionsDnsServers.Add("10.1.1.1");
         vnetData.DhcpOptionsDnsServers.Add("10.1.2.4");
         VirtualNetworkResource vnet = (await ResGroup.GetVirtualNetworks().CreateOrUpdateAsync(WaitUntil.Completed, VnetName, vnetData)).Value;
         PrivateEndpointData    privateEndpointData = new PrivateEndpointData()
         {
             Location = "eastus",
             PrivateLinkServiceConnections = { new PrivateLinkServiceConnection()
                                               {
                                                   Name = "myconnection",
                                                   PrivateLinkServiceId = ConfigStore.Data.Id,
                                                   GroupIds             = { "configurationStores" },
                                                   RequestMessage       = "Please approve my connection",
                                               } },
             Subnet = new SubnetData()
             {
                 Id = "/subscriptions/" + TestEnvironment.SubscriptionId + "/resourceGroups/" + groupName + "/providers/Microsoft.Network/virtualNetworks/" + VnetName + "/subnets/" + SubnetName
             }
         };
         PrivateEndpointResource = (await ResGroup.GetPrivateEndpoints().CreateOrUpdateAsync(WaitUntil.Completed, EndpointName, privateEndpointData)).Value;
     }
 }
示例#11
0
        public async Task GetIfExistsTest()
        {
            string configurationStoreName = Recording.GenerateAssetName("testapp-");
            ConfigurationStoreData configurationStoreData = new ConfigurationStoreData(Location, new Models.Sku("Standard"))
            {
                PublicNetworkAccess = PublicNetworkAccess.Disabled
            };
            await ResGroup.GetConfigurationStores().CreateOrUpdateAsync(true, configurationStoreName, configurationStoreData);

            ConfigurationStore configurationStore = await ResGroup.GetConfigurationStores().GetIfExistsAsync(configurationStoreName);

            Assert.IsTrue(configurationStore.Data.Name == configurationStoreName);

            configurationStore = await ResGroup.GetConfigurationStores().GetIfExistsAsync("foo");

            Assert.IsNull(configurationStore);
        }
示例#12
0
        public async Task GetAllTest()
        {
            string configurationStoreName1 = Recording.GenerateAssetName("testapp-");
            string configurationStoreName2 = Recording.GenerateAssetName("testapp-");
            ConfigurationStoreData configurationStoreData = new ConfigurationStoreData(Location, new AppConfigurationSku("Standard"))
            {
                PublicNetworkAccess = PublicNetworkAccess.Disabled
            };
            await ResGroup.GetConfigurationStores().CreateOrUpdateAsync(WaitUntil.Completed, configurationStoreName1, configurationStoreData);

            await ResGroup.GetConfigurationStores().CreateOrUpdateAsync(WaitUntil.Completed, configurationStoreName2, configurationStoreData);

            List <ConfigurationStoreResource> configurationStores = await ResGroup.GetConfigurationStores().GetAllAsync().ToEnumerableAsync();

            Assert.IsTrue(configurationStores.Count == 2);
            Assert.IsTrue(configurationStores.First(x => x.Data.Name == configurationStoreName1).Data.PublicNetworkAccess == PublicNetworkAccess.Disabled);
        }
示例#13
0
        public async Task CreateOrUpdateTest()
        {
            string configurationStoreName = Recording.GenerateAssetName("testapp-");
            ConfigurationStoreData configurationStoreData = new ConfigurationStoreData(Location, new AppConfigurationSku("Standard"))
            {
                PublicNetworkAccess = PublicNetworkAccess.Disabled
            };
            ConfigurationStoreResource configurationStore = (await ResGroup.GetConfigurationStores().CreateOrUpdateAsync(WaitUntil.Completed, configurationStoreName, configurationStoreData)).Value;

            Assert.IsTrue(configurationStoreName.Equals(configurationStore.Data.Name));
            Assert.IsTrue(configurationStore.Data.PublicNetworkAccess == PublicNetworkAccess.Disabled);

            configurationStore.Data.PublicNetworkAccess = PublicNetworkAccess.Enabled;
            configurationStore = (await ResGroup.GetConfigurationStores().CreateOrUpdateAsync(WaitUntil.Completed, configurationStoreName, configurationStore.Data)).Value;

            Assert.IsTrue(configurationStore.Data.PublicNetworkAccess == PublicNetworkAccess.Enabled);
        }