Java Code Examples for com.microsoft.azure.management.resources.fluentcore.arm.Region#US_EAST
The following examples show how to use
com.microsoft.azure.management.resources.fluentcore.arm.Region#US_EAST .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DnsZoneRecordSetETagTests.java From azure-libraries-for-java with MIT License | 6 votes |
@Test public void canCreateZoneWithDefaultETag() throws Exception { final Region region = Region.US_EAST; final String topLevelDomain = "www.contoso" + generateRandomResourceName("z", 10) + ".com"; DnsZone dnsZone = zoneManager.zones().define(topLevelDomain) .withNewResourceGroup(RG_NAME, region) .withETagCheck() .create(); Assert.assertNotNull(dnsZone.eTag()); Action0 action = new Action0() { @Override public void call() { zoneManager.zones().define(topLevelDomain) .withNewResourceGroup(RG_NAME, region) .withETagCheck() .create(); } }; ensureETagExceptionIsThrown(action); }
Example 2
Source File: DnsZoneRecordSetETagTests.java From azure-libraries-for-java with MIT License | 6 votes |
@Test public void canUpdateZoneWithExplicitETag() throws Exception { final Region region = Region.US_EAST; final String topLevelDomain = "www.contoso" + generateRandomResourceName("z", 10) + ".com"; final DnsZone dnsZone = zoneManager.zones().define(topLevelDomain) .withNewResourceGroup(RG_NAME, region) .withETagCheck() .create(); Assert.assertNotNull(dnsZone.eTag()); Action0 action = new Action0() { @Override public void call() { dnsZone.update() .withETagCheck(dnsZone.eTag() + "-foo") .apply(); } }; ensureETagExceptionIsThrown(action); dnsZone.update() .withETagCheck(dnsZone.eTag()) .apply(); }
Example 3
Source File: DnsZoneRecordSetETagTests.java From azure-libraries-for-java with MIT License | 6 votes |
@Test public void canDeleteZoneWithExplicitETag() throws Exception { final Region region = Region.US_EAST; final String topLevelDomain = "www.contoso" + generateRandomResourceName("z", 10) + ".com"; final DnsZone dnsZone = zoneManager.zones().define(topLevelDomain) .withNewResourceGroup(RG_NAME, region) .withETagCheck() .create(); Assert.assertNotNull(dnsZone.eTag()); Action0 action = new Action0() { @Override public void call() { zoneManager.zones().deleteById(dnsZone.id(), dnsZone.eTag() + "-foo"); } }; ensureETagExceptionIsThrown(action); zoneManager.zones().deleteById(dnsZone.id(), dnsZone.eTag()); }
Example 4
Source File: ApplicationGatewayTests.java From azure-libraries-for-java with MIT License | 5 votes |
@Test public void testAppGatewaysStartStop() throws Exception { String rgName = SdkContext.randomResourceName("rg", 13); Region region = Region.US_EAST; String name = SdkContext.randomResourceName("ag", 15); ApplicationGateway appGateway = azure.applicationGateways().define(name) .withRegion(region) .withNewResourceGroup(rgName) // Request routing rules .defineRequestRoutingRule("rule1") .fromPrivateFrontend() .fromFrontendHttpPort(80) .toBackendHttpPort(8080) .toBackendIPAddress("11.1.1.1") .toBackendIPAddress("11.1.1.2") .attach() .create(); // Test stop/start appGateway.stop(); Assert.assertEquals(ApplicationGatewayOperationalState.STOPPED, appGateway.operationalState()); appGateway.start(); Assert.assertEquals(ApplicationGatewayOperationalState.RUNNING, appGateway.operationalState()); azure.resourceGroups().beginDeleteByName(rgName); }
Example 5
Source File: TestNetworkInterface.java From azure-libraries-for-java with MIT License | 4 votes |
@Override public NetworkInterface createResource(NetworkInterfaces networkInterfaces) throws Exception { final String nicName = "nic" + this.testId; final String vnetName = "net" + this.testId; final String pipName = "pip" + this.testId; final Region region = Region.US_EAST; Network network = networkInterfaces.manager().networks().define(vnetName) .withRegion(region) .withNewResourceGroup() .withAddressSpace("10.0.0.0/28") .withSubnet("subnet1", "10.0.0.0/29") .withSubnet("subnet2", "10.0.0.8/29") .create(); NetworkInterface nic = networkInterfaces.define(nicName) .withRegion(region) .withExistingResourceGroup(network.resourceGroupName()) .withExistingPrimaryNetwork(network) .withSubnet("subnet1") .withPrimaryPrivateIPAddressDynamic() .withNewPrimaryPublicIPAddress(pipName) .withIPForwarding() .withAcceleratedNetworking() .create(); // Verify NIC settings Assert.assertTrue(nic.isAcceleratedNetworkingEnabled()); Assert.assertTrue(nic.isIPForwardingEnabled()); // Verify IP configs NicIPConfiguration ipConfig = nic.primaryIPConfiguration(); Assert.assertNotNull(ipConfig); network = ipConfig.getNetwork(); Assert.assertNotNull(network); Subnet subnet = network.subnets().get(ipConfig.subnetName()); Assert.assertNotNull(subnet); Assert.assertEquals(1, subnet.networkInterfaceIPConfigurationCount()); Collection<NicIPConfiguration> ipConfigs = subnet.listNetworkInterfaceIPConfigurations(); Assert.assertNotNull(ipConfigs); Assert.assertEquals(1, ipConfigs.size()); NicIPConfiguration ipConfig2 = null; for (NicIPConfiguration i : ipConfigs) { if (i.name().equalsIgnoreCase(ipConfig.name())) { ipConfig2 = i; break; } } Assert.assertNotNull(ipConfig2); Assert.assertTrue(ipConfig.name().equalsIgnoreCase(ipConfig2.name())); return nic; }
Example 6
Source File: TestNetwork.java From azure-libraries-for-java with MIT License | 4 votes |
@Override public Network createResource(Networks networks) throws Exception { Region region = Region.US_EAST; String groupName = "rg" + this.testId; String networkName = SdkContext.randomResourceName("net", 15); String networkName2 = SdkContext.randomResourceName("net", 15); Creatable<Network> remoteNetworkDefinition = networks.define(networkName2) .withRegion(region) .withNewResourceGroup(groupName) .withAddressSpace("10.1.0.0/27") .withSubnet("subnet3", "10.1.0.0/27"); Creatable<Network> localNetworkDefinition = networks.define(networkName) .withRegion(region) .withNewResourceGroup(groupName) .withAddressSpace("10.0.0.0/27") .withSubnet("subnet1", "10.0.0.0/28") .withSubnet("subnet2", "10.0.0.16/28"); CreatedResources<Network> createdNetworks = networks.create(Arrays.asList(remoteNetworkDefinition, localNetworkDefinition)); Network localNetwork = createdNetworks.get(localNetworkDefinition.key()); Network remoteNetwork = createdNetworks.get(remoteNetworkDefinition.key()); Assert.assertNotNull(localNetwork); Assert.assertNotNull(remoteNetwork); // Create peering NetworkPeering localPeering = localNetwork.peerings().define("peer0") .withRemoteNetwork(remoteNetwork) // Optionals .withTrafficForwardingBetweenBothNetworks() .withoutAccessFromEitherNetwork() .withGatewayUseByRemoteNetworkAllowed() .create(); // Verify local peering Assert.assertNotNull(localNetwork.peerings()); Assert.assertEquals(1, localNetwork.peerings().list().size()); Assert.assertEquals(1, localPeering.remoteAddressSpaces().size()); Assert.assertEquals("10.1.0.0/27", localPeering.remoteAddressSpaces().get(0)); localPeering = localNetwork.peerings().list().get(0); Assert.assertNotNull(localPeering); Assert.assertTrue(localPeering.name().equalsIgnoreCase("peer0")); Assert.assertEquals(VirtualNetworkPeeringState.CONNECTED, localPeering.state()); Assert.assertTrue(localPeering.isTrafficForwardingFromRemoteNetworkAllowed()); Assert.assertFalse(localPeering.checkAccessBetweenNetworks()); Assert.assertEquals(NetworkPeeringGatewayUse.BY_REMOTE_NETWORK, localPeering.gatewayUse()); // Verify remote peering Assert.assertNotNull(remoteNetwork.peerings()); Assert.assertEquals(1, remoteNetwork.peerings().list().size()); NetworkPeering remotePeering = localPeering.getRemotePeering(); Assert.assertNotNull(remotePeering); Assert.assertTrue(remotePeering.remoteNetworkId().equalsIgnoreCase(localNetwork.id())); Assert.assertEquals(VirtualNetworkPeeringState.CONNECTED, remotePeering.state()); Assert.assertTrue(remotePeering.isTrafficForwardingFromRemoteNetworkAllowed()); Assert.assertFalse(remotePeering.checkAccessBetweenNetworks()); Assert.assertEquals(NetworkPeeringGatewayUse.NONE, remotePeering.gatewayUse()); return localNetwork; }
Example 7
Source File: AzureTests.java From azure-libraries-for-java with MIT License | 4 votes |
@Test @Ignore("Deprecated") public void testBatchAIJob() throws Exception { final Region region = Region.US_EAST; final String groupName = SdkContext.randomResourceName("rg", 10); final String workspaceName = SdkContext.randomResourceName("ws", 10); final String clusterName = SdkContext.randomResourceName("cluster", 15); final String experimentName = SdkContext.randomResourceName("exp", 10); final String userName = "tirekicker"; try { BatchAIWorkspace workspace = azure.batchAIWorkspaces().define(workspaceName) .withRegion(region) .withNewResourceGroup(groupName) .create(); BatchAIExperiment experiment = workspace.experiments().define(experimentName).create(); BatchAICluster cluster = workspace.clusters().define(clusterName) .withVMSize(VirtualMachineSizeTypes.STANDARD_D1_V2.toString()) .withUserName(userName) .withPassword("MyPassword") .withAutoScale(1, 1) .create(); Assert.assertEquals("resizing", cluster.allocationState().toString()); Assert.assertEquals(userName, cluster.adminUserName()); BatchAIJob job = experiment.jobs().define("myJob") .withExistingClusterId(cluster.id()) .withNodeCount(1) .withStdOutErrPathPrefix("$AZ_BATCHAI_MOUNT_ROOT/azurefileshare") .defineCognitiveToolkit() .withPythonScriptFile("$AZ_BATCHAI_INPUT_SAMPLE/ConvNet_MNIST.py") .withCommandLineArgs("$AZ_BATCHAI_INPUT_SAMPLE $AZ_BATCHAI_OUTPUT_MODEL") .attach() .withInputDirectory("SAMPLE", "$AZ_BATCHAI_MOUNT_ROOT/azurefileshare/mnistcntksample") .withOutputDirectory("MODEL", "$AZ_BATCHAI_MOUNT_ROOT/azurefileshare/model") .defineOutputDirectory("OUTPUT") .withPathPrefix("$AZ_BATCHAI_MOUNT_ROOT/azurefileshare/output") .withPathSuffix("suffix") .attach() .withContainerImage("microsoft/cntk:2.1-gpu-python3.5-cuda8.0-cudnn6.0") .create(); Assert.assertEquals(2,job.outputDirectories().size()); OutputDirectory outputDirectory = null; for (OutputDirectory directory : job.outputDirectories()) { if ("OUTPUT".equalsIgnoreCase(directory.id())) { outputDirectory = directory; } } Assert.assertNotNull(outputDirectory); Assert.assertEquals("suffix", outputDirectory.pathSuffix().toLowerCase()); experiment.jobs().list(); BatchAIJob job2 = experiment.jobs().getById(job.id()); Assert.assertEquals(cluster.id(), job2.cluster().id()); } finally { azure.resourceGroups().beginDeleteByName(groupName); } }
Example 8
Source File: ManageSqlServerSecurityAlertPolicy.java From azure-libraries-for-java with MIT License | 4 votes |
/** * Main function which runs the actual sample. * @param azure instance of the azure client * @return true if sample runs successfully */ public static boolean runSample(Azure azure) { final String sqlServerName = Utils.createRandomName("sql"); final String storageAccountName = Utils.createRandomName("sqlsa"); final String rgName = Utils.createRandomName("rgsql"); final Region region = Region.US_EAST; final String dbName = "dbSample"; final String administratorLogin = "sqladmin3423"; // [SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Serves as an example, not for deployment. Please change when using this in your code.")] final String administratorPassword = "myS3cureP@ssword"; try { // ============================================================ // Create a primary SQL Server with a sample database. System.out.println("Creating a primary SQL Server with a sample database"); SqlServer sqlServer = azure.sqlServers().define(sqlServerName) .withRegion(region) .withNewResourceGroup(rgName) .withAdministratorLogin(administratorLogin) .withAdministratorPassword(administratorPassword) .defineDatabase(dbName) .fromSample(SampleName.ADVENTURE_WORKS_LT) .withStandardEdition(SqlDatabaseStandardServiceObjective.S0) .attach() .create(); Utils.print(sqlServer); // ============================================================ // Create an Azure Storage Account and get the storage account blob entry point. System.out.println("Creating an Azure Storage Account and a storage account blob"); StorageAccount storageAccount = azure.storageAccounts().define(storageAccountName) .withRegion(region) .withExistingResourceGroup(rgName) .create(); String accountKey = storageAccount.getKeys().get(0).value(); String blobEntrypoint = storageAccount.endPoints().primary().blob(); // ============================================================ // Create a Server Security Alert Policy. System.out.println("Creating a Server Security Alert Policy"); sqlServer.serverSecurityAlertPolicies().define() .withState(SecurityAlertPolicyState.ENABLED) .withEmailAccountAdmins() .withStorageEndpoint(blobEntrypoint, accountKey) .withDisabledAlerts("Access_Anomaly", "Sql_Injection") .withRetentionDays(5) .create(); // ============================================================ // Get the Server Security Alert Policy. System.out.println("Getting the Server Security Alert Policy"); SqlServerSecurityAlertPolicy sqlSecurityAlertPolicy = sqlServer.serverSecurityAlertPolicies().get(); // ============================================================ // Update the Server Security Alert Policy. System.out.println("Updating the Server Security Alert Policy"); sqlSecurityAlertPolicy = sqlSecurityAlertPolicy.update() .withoutEmailAccountAdmins() .withEmailAddresses("[email protected]") .withRetentionDays(1) .apply(); // Delete the SQL Servers. System.out.println("Deleting the Sql Servers"); azure.sqlServers().deleteById(sqlServer.id()); return true; } catch (Exception f) { System.out.println(f.getMessage()); f.printStackTrace(); } finally { try { System.out.println("Deleting Resource Group: " + rgName); azure.resourceGroups().deleteByName(rgName); System.out.println("Deleted Resource Group: " + rgName); } catch (Exception e) { System.out.println("Did not create any resources in Azure. No clean up is necessary"); } } return false; }
Example 9
Source File: ServiceBusOperationsTests.java From azure-libraries-for-java with MIT License | 4 votes |
@Test public void canCreateNamespaceThenCRUDOnQueue() { Region region = Region.US_EAST; Creatable<ResourceGroup> rgCreatable = resourceManager.resourceGroups() .define(RG_NAME) .withRegion(region); String namespaceDNSLabel = generateRandomResourceName("jvsbns", 15); ServiceBusNamespace namespace = serviceBusManager.namespaces() .define(namespaceDNSLabel) .withRegion(region) .withNewResourceGroup(rgCreatable) .withSku(NamespaceSku.STANDARD) .create(); Assert.assertNotNull(namespace); Assert.assertNotNull(namespace.inner()); String queueName = generateRandomResourceName("queue1-", 15); Queue queue = namespace.queues() .define(queueName) .create(); Assert.assertNotNull(queue); Assert.assertNotNull(queue.inner()); Assert.assertNotNull(queue.name()); Assert.assertTrue(queue.name().equalsIgnoreCase(queueName)); // Default lock duration is 1 minute, assert TimeSpan("00:01:00") parsing // Assert.assertEquals("00:01:00", queue.inner().lockDuration()); Assert.assertEquals(60, queue.lockDurationInSeconds()); Period dupDetectionDuration = queue.duplicateMessageDetectionHistoryDuration(); Assert.assertNotNull(dupDetectionDuration); Assert.assertEquals(10, dupDetectionDuration.getMinutes()); // Default message TTL is TimeSpan.Max, assert parsing // Assert.assertEquals("10675199.02:48:05.4775807", queue.inner().defaultMessageTimeToLive()); Period msgTtlDuration = queue.defaultMessageTtlDuration(); Assert.assertNotNull(msgTtlDuration); // Assert the default ttl TimeSpan("10675199.02:48:05.4775807") parsing // Assert.assertEquals(10675199, msgTtlDuration.getDays()); Assert.assertEquals(2, msgTtlDuration.getHours()); Assert.assertEquals(48, msgTtlDuration.getMinutes()); // Assert the default max size In MB // Assert.assertEquals(1024, queue.maxSizeInMB()); PagedList<Queue> queuesInNamespace = namespace.queues().list(); Assert.assertNotNull(queuesInNamespace); Assert.assertTrue(queuesInNamespace.size() > 0); Queue foundQueue = null; for (Queue q : queuesInNamespace) { if (q.name().equalsIgnoreCase(queueName)) { foundQueue = q; break; } } Assert.assertNotNull(foundQueue); // Dead lettering disabled by default // Assert.assertFalse(foundQueue.isDeadLetteringEnabledForExpiredMessages()); foundQueue = foundQueue.update() .withMessageLockDurationInSeconds(120) .withDefaultMessageTTL(new Period().withMinutes(20)) .withExpiredMessageMovedToDeadLetterQueue() .withMessageMovedToDeadLetterQueueOnMaxDeliveryCount(25) .apply(); Assert.assertEquals(120, foundQueue.lockDurationInSeconds()); Assert.assertTrue(foundQueue.isDeadLetteringEnabledForExpiredMessages()); Assert.assertEquals(25, foundQueue.maxDeliveryCountBeforeDeadLetteringMessage()); namespace.queues().deleteByName(foundQueue.name()); }
Example 10
Source File: ServiceBusOperationsTests.java From azure-libraries-for-java with MIT License | 4 votes |
@Test public void canCreateDeleteQueueWithNamespace() { Region region = Region.US_EAST; Creatable<ResourceGroup> rgCreatable = resourceManager.resourceGroups() .define(RG_NAME) .withRegion(region); String namespaceDNSLabel = generateRandomResourceName("jvsbns", 15); String queueName = generateRandomResourceName("queue1-", 15); // Create NS with Queue // ServiceBusNamespace namespace = serviceBusManager.namespaces() .define(namespaceDNSLabel) .withRegion(region) .withNewResourceGroup(rgCreatable) .withSku(NamespaceSku.STANDARD) .withNewQueue(queueName, 1024) .create(); Assert.assertNotNull(namespace); Assert.assertNotNull(namespace.inner()); // Lookup queue // PagedList<Queue> queuesInNamespace = namespace.queues().list(); Assert.assertNotNull(queuesInNamespace); Assert.assertEquals(1, queuesInNamespace.size()); Queue foundQueue = null; for (Queue q : queuesInNamespace) { if (q.name().equalsIgnoreCase(queueName)) { foundQueue = q; break; } } Assert.assertNotNull(foundQueue); // Remove Queue // namespace.update() .withoutQueue(queueName) .apply(); queuesInNamespace = namespace.queues().list(); Assert.assertNotNull(queuesInNamespace); Assert.assertEquals(0, queuesInNamespace.size()); }
Example 11
Source File: ServiceBusOperationsTests.java From azure-libraries-for-java with MIT License | 4 votes |
@Test public void canCreateNamespaceThenCRUDOnTopic() { Region region = Region.US_EAST; Creatable<ResourceGroup> rgCreatable = resourceManager.resourceGroups() .define(RG_NAME) .withRegion(region); String namespaceDNSLabel = generateRandomResourceName("jvsbns", 15); ServiceBusNamespace namespace = serviceBusManager.namespaces() .define(namespaceDNSLabel) .withRegion(region) .withNewResourceGroup(rgCreatable) .withSku(NamespaceSku.STANDARD) .create(); Assert.assertNotNull(namespace); Assert.assertNotNull(namespace.inner()); String topicName = generateRandomResourceName("topic1-", 15); Topic topic = namespace.topics() .define(topicName) .create(); Assert.assertNotNull(topic); Assert.assertNotNull(topic.inner()); Assert.assertNotNull(topic.name()); Assert.assertTrue(topic.name().equalsIgnoreCase(topicName)); Period dupDetectionDuration = topic.duplicateMessageDetectionHistoryDuration(); Assert.assertNotNull(dupDetectionDuration); Assert.assertEquals(10, dupDetectionDuration.getMinutes()); // Default message TTL is TimeSpan.Max, assert parsing // Assert.assertEquals("10675199.02:48:05.4775807", topic.inner().defaultMessageTimeToLive()); Period msgTtlDuration = topic.defaultMessageTtlDuration(); Assert.assertNotNull(msgTtlDuration); // Assert the default ttl TimeSpan("10675199.02:48:05.4775807") parsing // Assert.assertEquals(10675199, msgTtlDuration.getDays()); Assert.assertEquals(2, msgTtlDuration.getHours()); Assert.assertEquals(48, msgTtlDuration.getMinutes()); // Assert the default max size In MB // Assert.assertEquals(1024, topic.maxSizeInMB()); PagedList<Topic> topicsInNamespace = namespace.topics().list(); Assert.assertNotNull(topicsInNamespace); Assert.assertTrue(topicsInNamespace.size() > 0); Topic foundTopic = null; for (Topic t : topicsInNamespace) { if (t.name().equalsIgnoreCase(topic.name())) { foundTopic = t; break; } } Assert.assertNotNull(foundTopic); foundTopic = foundTopic.update() .withDefaultMessageTTL(new Period().withMinutes(20)) .withDuplicateMessageDetectionHistoryDuration(new Period().withMinutes(15)) .withDeleteOnIdleDurationInMinutes(25) .apply(); Period ttlDuration = foundTopic.defaultMessageTtlDuration(); Assert.assertNotNull(ttlDuration); Assert.assertEquals(20, ttlDuration.getMinutes()); Period duplicateDetectDuration = foundTopic.duplicateMessageDetectionHistoryDuration(); Assert.assertNotNull(duplicateDetectDuration); Assert.assertEquals(15, duplicateDetectDuration.getMinutes()); Assert.assertEquals(25, foundTopic.deleteOnIdleDurationInMinutes()); // Delete namespace.topics().deleteByName(foundTopic.name()); }
Example 12
Source File: ServiceBusOperationsTests.java From azure-libraries-for-java with MIT License | 4 votes |
@Test public void canCreateDeleteTopicWithNamespace() { Region region = Region.US_EAST; Creatable<ResourceGroup> rgCreatable = resourceManager.resourceGroups() .define(RG_NAME) .withRegion(region); String namespaceDNSLabel = generateRandomResourceName("jvsbns", 15); String topicName = generateRandomResourceName("topic1-", 15); // Create NS with Topic // ServiceBusNamespace namespace = serviceBusManager.namespaces() .define(namespaceDNSLabel) .withRegion(region) .withNewResourceGroup(rgCreatable) .withSku(NamespaceSku.STANDARD) .withNewTopic(topicName, 1024) .create(); Assert.assertNotNull(namespace); Assert.assertNotNull(namespace.inner()); // Lookup topic // PagedList<Topic> topicsInNamespace = namespace.topics().list(); Assert.assertNotNull(topicsInNamespace); Assert.assertEquals(1, topicsInNamespace.size()); Topic foundTopic = null; for (Topic t : topicsInNamespace) { if (t.name().equalsIgnoreCase(topicName)) { foundTopic = t; break; } } Assert.assertNotNull(foundTopic); // Remove Topic // namespace.update() .withoutTopic(topicName) .apply(); topicsInNamespace = namespace.topics().list(); Assert.assertNotNull(topicsInNamespace); Assert.assertEquals(0, topicsInNamespace.size()); }
Example 13
Source File: ServiceBusOperationsTests.java From azure-libraries-for-java with MIT License | 4 votes |
@Test public void canPerformCRUDOnSubscriptions() { Region region = Region.US_EAST; Creatable<ResourceGroup> rgCreatable = resourceManager.resourceGroups() .define(RG_NAME) .withRegion(region); String namespaceDNSLabel = generateRandomResourceName("jvsbns", 15); String topicName = generateRandomResourceName("topic1-", 15); String subscriptionName = generateRandomResourceName("sub1-", 15); // Create NS with Topic // ServiceBusNamespace namespace = serviceBusManager.namespaces() .define(namespaceDNSLabel) .withRegion(region) .withNewResourceGroup(rgCreatable) .withSku(NamespaceSku.STANDARD) .withNewTopic(topicName, 1024) .create(); // Create Topic subscriptions and list it // Topic topic = namespace.topics().getByName(topicName); ServiceBusSubscription subscription = topic.subscriptions().define(subscriptionName) .withDefaultMessageTTL(new Period().withMinutes(20)) .create(); Assert.assertNotNull(subscription); Assert.assertNotNull(subscription.inner()); Assert.assertEquals(20, subscription.defaultMessageTtlDuration().getMinutes()); subscription = topic.subscriptions().getByName(subscriptionName); Assert.assertNotNull(subscription); Assert.assertNotNull(subscription.inner()); PagedList<ServiceBusSubscription> subscriptionsInTopic = topic.subscriptions().list(); Assert.assertTrue(subscriptionsInTopic.size() > 0); boolean foundSubscription = false; for (ServiceBusSubscription s : subscriptionsInTopic) { if (s.name().equalsIgnoreCase(subscription.name())) { foundSubscription = true; break; } } Assert.assertTrue(foundSubscription); topic.subscriptions().deleteByName(subscriptionName); subscriptionsInTopic = topic.subscriptions().list(); Assert.assertTrue(subscriptionsInTopic.size() == 0); }