com.microsoft.azure.management.Azure Java Examples

The following examples show how to use com.microsoft.azure.management.Azure. 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: ListComputeSkus.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * The main entry point.
 *
 * @param args the parameters
 */
public static void main(String[] args) {
    try {
        //=================================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
                .withLogLevel(LogLevel.NONE)
                .authenticate(credFile)
                .withDefaultSubscription();

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #2
Source File: ManageVirtualMachineScaleSet.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args parameters
 */

public static void main(String[] args) {
    try {

        //=============================================================
        // Authenticate

        System.out.println(System.getenv("AZURE_AUTH_LOCATION"));
        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
                .withLogLevel(LogLevel.BASIC)
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);

    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #3
Source File: ManageSqlVirtualNetworkRules.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args the parameters
 */
public static void main(String[] args) {
    try {
        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));


        ApplicationTokenCredentials credentials = ApplicationTokenCredentials.fromFile(credFile);
        RestClient restClient = new RestClient.Builder()
            .withBaseUrl(AzureEnvironment.AZURE, AzureEnvironment.Endpoint.RESOURCE_MANAGER)
            .withSerializerAdapter(new AzureJacksonAdapter())
            .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
            .withReadTimeout(150, TimeUnit.SECONDS)
            .withLogLevel(LogLevel.BODY)
            .withCredentials(credentials).build();
        Azure azure = Azure.authenticate(restClient, credentials.domain(), credentials.defaultSubscriptionId()).withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #4
Source File: ManageStorageFromMSIEnabledVirtualMachine.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args the parameters
 */
public static void main(String[] args) {
    try {
        //=============================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
                .withLogLevel(LogLevel.BODY_AND_HEADERS)
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #5
Source File: ManageContainerInstanceZeroToOneAndOneToManyUsingContainerServiceOrchestrator.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 *
 * @param args the parameters
 */
public static void main(String[] args) {
    try {
        //=============================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
            .withLogLevel(LogLevel.BODY)
            .authenticate(credFile)
            .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure, "", "");
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #6
Source File: ManageContainerRegistryWithWebhooks.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 *
 * @param args the parameters
 */
public static void main(String[] args) {
    try {
        //=============================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
            .withLogLevel(LogLevel.BODY)
            .authenticate(credFile)
            .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #7
Source File: ManageWebAppWithDomainSsl.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args the parameters
 */
public static void main(String[] args) {


    try {

        //=============================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
                .withLogLevel(LogLevel.BODY)
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);

    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #8
Source File: ManageNetworkInterface.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args the parameters
 */
public static void main(String[] args) {
    try {

        //=============================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
                .withLogLevel(LogLevel.BASIC)
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #9
Source File: ManageNetworkPeeringInSameSubscription.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args parameters
 */

public static void main(String[] args) {
    try {

        //=============================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure
                .configure()
                .withLogLevel(LogLevel.BODY.withPrettyJson(true))
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #10
Source File: ManageLinuxWebAppSqlConnection.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args the parameters
 */
public static void main(String[] args) {
    try {

        //=============================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
                .withLogLevel(LogLevel.BASIC)
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #11
Source File: CreateVirtualMachineUsingCustomImageFromVHD.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args the parameters
 */
public static void main(String[] args) {
    try {
        //=============================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
                .withLogLevel(LogLevel.BODY)
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #12
Source File: ManageWebAppSqlConnection.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args the parameters
 */
public static void main(String[] args) {
    try {

        //=============================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
                .withLogLevel(LogLevel.BASIC)
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #13
Source File: ManageZonalVirtualMachineScaleSet.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args the parameters
 */
public static void main(String[] args) {
    try {

        //=============================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
                .withLogLevel(LogLevel.BODY_AND_HEADERS)
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #14
Source File: ServiceBusWithClaimBasedAuthorization.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args the parameters
 */
public static void main(String[] args) {
    try {

        //=============================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure
                .configure()
                .withLogLevel(LogLevel.BODY_AND_HEADERS)
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());
        runSample(azure);

    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #15
Source File: AutoscaleSettingsBasedOnPerformanceOrSchedule.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args the parameters
 */
public static void main(String[] args) {
    try {

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
                .withLogLevel(LogLevel.NONE)
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #16
Source File: ManageExpressRouteCrossConnection.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args the parameters
 */
public static void main(String[] args) {
    try {
        //=============================================================
        // Authenticate
        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
                .withLogLevel(LogLevel.BODY)
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #17
Source File: ManageVirtualMachine.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args the parameters
 */
public static void main(String[] args) {
    try {

        //=============================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
                .withLogLevel(LogLevel.BASIC)
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #18
Source File: ManageVirtualMachineWithDisk.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args the parameters
 */
public static void main(String[] args) {
    try {

        //=============================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
                .withLogLevel(LogLevel.BODY)
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #19
Source File: CreateVirtualMachinesInParallel.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args the parameters
 */
public static void main(String[] args) {
    try {

        //=============================================================
        // Authenticate
        //
        System.out.println("AZURE_AUTH_LOCATION_2=" + System.getenv("AZURE_AUTH_LOCATION_2"));
        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION_2"));

        Azure azure = Azure
                .configure()
                .withLogLevel(LogLevel.NONE)
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }

}
 
Example #20
Source File: ManageTrafficManager.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args the parameters
 */
public static void main(String[] args) {
    try {
        //=============================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
                .withLogLevel(LogLevel.BASIC)
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #21
Source File: ManageApplicationGateway.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args parameters
 */

public static void main(String[] args) {
    try {

        //=============================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
                .withLogLevel(LogLevel.NONE)
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #22
Source File: ManageExpressRoute.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args the parameters
 */
public static void main(String[] args) {
    try {
        //=============================================================
        // Authenticate
        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
                .withLogLevel(LogLevel.BODY)
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #23
Source File: ManageInternalLoadBalancer.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args parameters.\
 */

public static void main(String[] args) {
    try {

        //=============================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
                .withLogLevel(LogLevel.BODY)
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #24
Source File: ConvertVirtualMachineToManagedDisks.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args the parameters
 */
public static void main(String[] args) {
    try {
        //=============================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
                .withLogLevel(LogLevel.BODY)
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #25
Source File: AzureClients.java    From clouditor with Apache License 2.0 6 votes vote down vote up
/**
 * Authenticates, either using an authentication file or the azure cli access tokens. See
 * https://github.com/Azure/azure-sdk-for-java/blob/master/AUTH.md for details.
 */
private void authenticate() throws IOException {
  // fetch information about the account
  var account = PersistenceManager.getInstance().getById(AzureAccount.class, "Azure");

  if (account == null) {
    throw new IOException("Azure not configured");
  }

  var credentials = account.resolveCredentials();

  this.azure = Azure.authenticate(credentials).withDefaultSubscription();

  this.monitor =
      MonitorManager.authenticate(
          credentials, this.azure.getCurrentSubscription().subscriptionId());

  LOGGER.info("Successfully created Azure client");
}
 
Example #26
Source File: CreateVirtualMachinesUsingCustomImageOrSpecializedVHD.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args the parameters
 */
public static void main(String[] args) {
    try {
        //=============================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
                .withLogLevel(LogLevel.BASIC)
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #27
Source File: ManageContainerInstanceWithManualAzureFileShareMountCreation.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 *
 * @param args the parameters
 */
public static void main(String[] args) {
    try {
        //=============================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
            .withLogLevel(LogLevel.BODY)
            .authenticate(credFile)
            .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #28
Source File: ManageEventHub.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args the parameters
 */
public static void main(String[] args) {
    try {
        //=============================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
                .withLogLevel(LogLevel.BASIC)
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #29
Source File: ManageWebAppStorageAccountConnection.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Main entry point.
 * @param args the parameters
 */
public static void main(String[] args) {


    try {

        //=============================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure()
                .withLogLevel(LogLevel.BASIC)
                .authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
 
Example #30
Source File: AzureFileSystemBehaviorITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
private static boolean isHttpsTrafficOnly() throws IOException {
	if (StringUtils.isNullOrWhitespaceOnly(RESOURCE_GROUP) || StringUtils.isNullOrWhitespaceOnly(TOKEN_CREDENTIALS_FILE)) {
		// default to https only, as some fields are missing
		return true;
	}

	Assume.assumeTrue("Azure storage account not configured, skipping test...", !StringUtils.isNullOrWhitespaceOnly(ACCOUNT));

	AzureTokenCredentials credentials = ApplicationTokenCredentials.fromFile(new File(TOKEN_CREDENTIALS_FILE));
	Azure azure =
		StringUtils.isNullOrWhitespaceOnly(SUBSCRIPTION_ID) ?
			Azure.authenticate(credentials).withDefaultSubscription() :
			Azure.authenticate(credentials).withSubscription(SUBSCRIPTION_ID);

	return azure.storageAccounts().getByResourceGroup(RESOURCE_GROUP, ACCOUNT).inner().enableHttpsTrafficOnly();
}