![]() ![]() If you want to use an existing disk instead of a marketplace image, use this code: Disk managedDisk = azure.disks().define("myosdisk") To learn more about selecting other images, see Navigate and select Azure virtual machine images with Windows PowerShell and the Azure CLI. This tutorial creates a virtual machine running a version of the Windows Server operating system. ("Press enter to get information about the VM.") withExistingAvailabilitySet(availabilitySet) ![]() withLatestWindowsImage("MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter") withExistingPrimaryNetworkInterface(networkInterface) VirtualMachine virtualMachine = azure.virtualMachines() To create the virtual machine, add this code to the try block in the main method: ("Creating virtual machine.") Now that you created all the supporting resources, you can create a virtual machine. withExistingPrimaryPublicIPAddress(publicIPAddress) NetworkInterface networkInterface = workInterfaces() ![]() To create a network interface, add this code to the try block in the main method: ("Creating network interface.") To create a subnet and a virtual network, add this code to the try block in the main method: ("Creating virtual network.") Ī virtual machine needs a network interface to communicate on the virtual network. PublicIpAddress publicIPAddress = azure.publicIpAddresses()Ī virtual machine must be in a subnet of a Virtual network. To create the public IP address for the virtual machine, add this code to the try block in the main method: ("Creating public IP address.") withExistingResourceGroup("myResourceGroup")Ī Public IP address is needed to communicate with the virtual machine. To create the availability set, add this code to the try block in the main method: ("Creating availability set.") ĪvailabilitySet availabilitySet = azure.availabilitySets() ResourceGroup resourceGroup = azure.resourceGroups()Īvailability sets make it easier for you to maintain the virtual machines used by your application. To specify values for the application and create the resource group, add this code to the try block in the main method: ("Creating resource group.") Please finish 'Set up authentication' step first to set the four environment variables: AZURE_SUBSCRIPTION_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_IDĪzureProfile profile = new AzureProfile(AzureEnvironment.AZURE) ĪzureResourceManager azureResourceManager = nfigure()Ĭreate resources Create the resource groupĪll resources must be contained in a Resource group. authorityHost(AzureAuthorityHosts.AZURE_PUBLIC_CLOUD) Open the App.java file under src\main\java\com\fabrikam and make sure this package statement is at the top: package Ĭreate AzureResourceManager: TokenCredential credential = new EnvironmentCredentialBuilder() Under the testAzureApp folder, open the pom.xml file and add the build configuration to to enable the building of your application: Īdd the dependencies that are needed to access the Azure Java SDK. Mvn archetype:generate -DgroupId=com.fabrikam -DartifactId=testAzureApp -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false If you haven't already done so, install Java.Ĭreate a new folder and the project: mkdir java-azure-test It takes about 20 minutes to do these steps. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |