use of com.microsoft.azure.toolkit.lib.applicationinsights.ApplicationInsightsEntity in project azure-tools-for-java by Microsoft.
the class FunctionAppService method bindApplicationInsights.
private void bindApplicationInsights(final Map<? super String, ? super String> appSettings, final FunctionAppConfig config) {
// Skip app insights creation when user specify ai connection string in app settings or disable ai in configuration
if (appSettings.containsKey(APPINSIGHTS_INSTRUMENTATION_KEY) || config.getMonitorConfig().getApplicationInsightsConfig() == null) {
return;
}
String instrumentationKey = config.getMonitorConfig().getApplicationInsightsConfig().getInstrumentationKey();
if (StringUtils.isEmpty(instrumentationKey)) {
final ApplicationInsightsEntity applicationInsightsComponent = getOrCreateApplicationInsights(config);
instrumentationKey = applicationInsightsComponent == null ? null : applicationInsightsComponent.getInstrumentationKey();
}
appSettings.put(APPINSIGHTS_INSTRUMENTATION_KEY, instrumentationKey);
}
use of com.microsoft.azure.toolkit.lib.applicationinsights.ApplicationInsightsEntity in project azure-tools-for-java by Microsoft.
the class FunctionAppService method createApplicationInsights.
@Nullable
private ApplicationInsightsEntity createApplicationInsights(final FunctionAppConfig config) {
try {
AzureMessager.getMessager().info(APPLICATION_INSIGHTS_CREATE_START);
final AzureEnvironment environment = Azure.az(AzureAccount.class).account().getEnvironment();
final ApplicationInsightsEntity resource = Azure.az(ApplicationInsights.class).create(config.getSubscription().getId(), config.getResourceGroup().getName(), config.getRegion(), config.getMonitorConfig().getApplicationInsightsConfig().getName());
AzureMessager.getMessager().info(String.format(APPLICATION_INSIGHTS_CREATED, resource.getName(), IdentityAzureManager.getInstance().getPortalUrl(), resource.getId()));
return resource;
} catch (final Exception e) {
AzureMessager.getMessager().warning(String.format(APPLICATION_INSIGHTS_CREATE_FAILED, e.getMessage()));
return null;
}
}
Aggregations