public async Task Get() { #region Snippet:Managing_WebPubSub_GetWebPubSub WebPubSubCollection WebPubSubColletion = resourceGroup.GetWebPubSubs(); WebPubSub webPubSub = await WebPubSubColletion.GetAsync("myWebPubSubName"); Console.WriteLine(webPubSub.Data.Name); #endregion }
public async Task DeleteVirtualWebPubSub() { #region Snippet:Managing_WebPubSub_DeleteWebPubSub WebPubSubCollection WebPubSubColletion = resourceGroup.GetWebPubSubs(); WebPubSub webPubSub = await WebPubSubColletion.GetAsync("myWebPubSubName"); await webPubSub.DeleteAsync(); #endregion }
public async Task List() { #region Snippet:Managing_WebPubSub_ListAllWebPubSub WebPubSubCollection WebPubSubColletion = resourceGroup.GetWebPubSubs(); AsyncPageable <WebPubSub> response = WebPubSubColletion.GetAllAsync(); await foreach (WebPubSub WebPubSub in response) { Console.WriteLine(WebPubSub.Data.Name); } #endregion }
public async Task GetIfExists() { #region Snippet:Managing_WebPubSub_GetWebPubSubIfExists WebPubSubCollection WebPubSubColletion = resourceGroup.GetWebPubSubs(); WebPubSub webPubSub = await WebPubSubColletion.GetIfExistsAsync("foo"); if (webPubSub != null) { Console.WriteLine(webPubSub.Data.Name); } if (await WebPubSubColletion.CheckIfExistsAsync("bar")) { Console.WriteLine("WebPubSub 'bar' exists."); } #endregion }
public async Task CreateOrUpdate() { #region Snippet:Managing_WebPubSub_CreateWebPubSub WebPubSubCollection WebPubSubColletion = resourceGroup.GetWebPubSubs(); string webPubSubName = "myWebPubSubName"; // Use the same location as the resource group IList <LiveTraceCategory> categories = new List <LiveTraceCategory>(); categories.Add(new LiveTraceCategory("category-01", "true")); AclAction aclAction = new AclAction("Deny"); IList <WebPubSubRequestType> allow = new List <WebPubSubRequestType>(); IList <WebPubSubRequestType> deny = new List <WebPubSubRequestType>(); deny.Add(new WebPubSubRequestType("RESTAPI")); NetworkAcl publicNetwork = new NetworkAcl(allow, deny); IList <PrivateEndpointAcl> privateEndpoints = new List <PrivateEndpointAcl>(); List <ResourceLogCategory> resourceLogCategory = new List <ResourceLogCategory>() { new ResourceLogCategory() { Name = "category1", Enabled = "false" } }; WebPubSubData data = new WebPubSubData(Location.WestUS2) { Sku = new WebPubSubSku("Standard_S1"), LiveTraceConfiguration = new LiveTraceConfiguration("true", categories), NetworkAcls = new WebPubSubNetworkAcls(aclAction, publicNetwork, privateEndpoints), ResourceLogConfiguration = new ResourceLogConfiguration(resourceLogCategory), }; WebPubSub webPubSub = await(await WebPubSubColletion.CreateOrUpdateAsync(webPubSubName, data)).WaitForCompletionAsync(); #endregion }
public async Task WebAppWebPubSubConnectionCRUD() { string resourceGroupName = Recording.GenerateAssetName("SdkRg"); string webAppName = Recording.GenerateAssetName("SdkWeb"); string webpubsubName = Recording.GenerateAssetName("SdkWebPubSub"); string linkerName = Recording.GenerateAssetName("SdkLinker"); // create resource group await ResourceGroups.CreateOrUpdateAsync(WaitUntil.Completed, resourceGroupName, new Resources.ResourceGroupData(DefaultLocation)); ResourceGroupResource resourceGroup = await ResourceGroups.GetAsync(resourceGroupName); // create web app WebSiteCollection webSites = resourceGroup.GetWebSites(); await webSites.CreateOrUpdateAsync(WaitUntil.Completed, webAppName, new WebSiteData(DefaultLocation)); WebSiteResource webapp = await webSites.GetAsync(webAppName); // create webpubsub WebPubSubCollection webPubSubs = resourceGroup.GetWebPubSubs(); WebPubSubData webPubSubData = new WebPubSubData(DefaultLocation) { Sku = new WebPubSub.Models.WebPubSubSku("Standard_S1"), LiveTraceConfiguration = new WebPubSub.Models.LiveTraceConfiguration(), NetworkAcls = new WebPubSub.Models.WebPubSubNetworkAcls { PublicNetwork = new WebPubSub.Models.NetworkAcl(), }, }; webPubSubData.LiveTraceConfiguration.Categories.Clear(); webPubSubData.NetworkAcls.PublicNetwork.Allow.Clear(); webPubSubData.NetworkAcls.PublicNetwork.Deny.Clear(); webPubSubData.ResourceLogCategories.Clear(); await webPubSubs.CreateOrUpdateAsync(WaitUntil.Completed, webpubsubName, webPubSubData); WebPubSubResource webPubSub = await webPubSubs.GetAsync(webpubsubName); // create service linker LinkerResourceCollection linkers = webapp.GetLinkerResources(); var linkerData = new LinkerResourceData { TargetService = new Models.AzureResource { Id = webPubSub.Id, }, AuthInfo = new SecretAuthInfo(), ClientType = ClientType.Dotnet, }; await linkers.CreateOrUpdateAsync(WaitUntil.Completed, linkerName, linkerData); // list service linker var linkerResources = await linkers.GetAllAsync().ToEnumerableAsync(); Assert.AreEqual(1, linkerResources.Count); Assert.AreEqual(linkerName, linkerResources[0].Data.Name); // get service linker LinkerResource linker = await linkers.GetAsync(linkerName); Assert.IsTrue(linker.Id.ToString().StartsWith(webapp.Id.ToString(), StringComparison.InvariantCultureIgnoreCase)); Assert.AreEqual(webPubSub.Id.ToString(), (linker.Data.TargetService as AzureResource).Id); Assert.AreEqual(AuthType.Secret, linker.Data.AuthInfo.AuthType); // get service linker configurations SourceConfigurationResult configurations = await linker.GetConfigurationsAsync(); foreach (var configuration in configurations.Configurations) { Assert.IsNotNull(configuration.Name); Assert.IsNotNull(configuration.Value); } // delete service linker var operation = await linker.DeleteAsync(WaitUntil.Completed); Assert.IsTrue(operation.HasCompleted); }