use of com.microsoft.azure.management.applicationinsights.v2015_05_01.implementation.InsightsManager in project azure-tools-for-java by Microsoft.
the class AzureSDKManager method createInsightsResource.
public static ApplicationInsightsComponent createInsightsResource(@NotNull String subscriptionId, @NotNull String resourceGroupName, @NotNull String resourceName, @NotNull String location) throws IOException {
final InsightsManager insightsManager = getInsightsManagerClient(subscriptionId);
if (insightsManager == null) {
// not signed in
return null;
}
final Azure azure = AuthMethodManager.getInstance().getAzureClient(subscriptionId);
if (!azure.resourceGroups().contain(resourceGroupName)) {
azure.resourceGroups().define(resourceGroupName).withRegion(location).create();
}
return insightsManager.components().define(resourceName).withRegion(location).withExistingResourceGroup(resourceGroupName).withApplicationType(ApplicationType.WEB).withKind("web").create();
}
use of com.microsoft.azure.management.applicationinsights.v2015_05_01.implementation.InsightsManager in project azure-tools-for-java by Microsoft.
the class AzureSDKManager method getOrCreateApplicationInsights.
// SDK will return existing application insights component when you create new one with existing name
// Use this method in case SDK service update their behavior
public static ApplicationInsightsComponent getOrCreateApplicationInsights(@NotNull String subscriptionId, @NotNull String resourceGroupName, @NotNull String resourceName, @NotNull String location) throws IOException {
final InsightsManager insightsManager = getInsightsManagerClient(subscriptionId);
if (insightsManager == null) {
return null;
}
ApplicationInsightsComponent component = null;
try {
component = insightsManager.components().getByResourceGroup(resourceGroupName, resourceName);
} catch (Exception e) {
// SDK will throw exception when resource not found
}
return component != null ? component : createInsightsResource(subscriptionId, resourceGroupName, resourceName, location);
}
use of com.microsoft.azure.management.applicationinsights.v2015_05_01.implementation.InsightsManager in project azure-tools-for-java by Microsoft.
the class AzureManagerBase method authApplicationInsights.
protected InsightsManager authApplicationInsights(String subscriptionId, String tenantId) {
final AzureTokenCredentials credentials = getCredentials(tenantId);
final InsightsManager.Configurable configurable = buildAzureManager(InsightsManager.configure()).withInterceptor(new TelemetryInterceptor());
Optional.ofNullable(createProxyFromConfig()).ifPresent(proxy -> {
configurable.withProxy(proxy);
Optional.ofNullable(createProxyAuthenticatorFromConfig()).ifPresent(configurable::withProxyAuthenticator);
});
return configurable.authenticate(credentials, subscriptionId);
}
Aggregations