Beispiel #1
0
        private static async Task RunAsync(Options opts, string usageReportContent)
        {
            var azureEnvironmentHelper = new AzureEnvironmentHelper(opts.AzureEnvironmentName);

            ParsedUsageReport usageReport = null;
            string            accessToken = null;

            if (usageReportContent == null)
            {
                var authenticationResult = await TokenProvider.AcquireTokenAsync(
                    azureEnvironmentHelper.AuthenticationEndpoint,
                    opts.TenantId,
                    azureEnvironmentHelper.ResourceManagerEndpoint);

                accessToken = authenticationResult.AccessToken;
            }
            else
            {
                usageReport = UsageFileHelper.Parse(usageReportContent);
            }

            var context = new AssessmentContext(
                usageReport: usageReport,
                subscriptionNames: opts.SubscriptionNames,
                subscriptionIds: opts.SubscriptionIds,
                resourceGroupNames: opts.ResourceGroupNames,
                accessToken: accessToken,
                armBaseUri: azureEnvironmentHelper.ResourceManagerEndpoint,
                resourceCachePath: opts.ResourceCachePath,
                configManager: ConfigManagerFactory.CreateStorageAccountConfigManager(Settings.Default.ConnectionString),
                telemetryManager: new TelemetryManager(
                    new AppInsightsTelemetryProvider(ConfigurationManager.AppSettings["ApplicationInsightsKey"]),
                    new Dictionary <string, string>
            {
                { "DeploymentId", $"console_debug_{Environment.MachineName}" }
            }));

            var assessmentService = new AssessmentService();
            var assessmentReport  = await assessmentService.GenerateReportAsync(context, opts.TargetLocation);

            if (File.Exists(assessmentReport.ReportFilePath))
            {
                Process.Start(assessmentReport.ReportFilePath);
            }
        }
Beispiel #2
0
 private static IConfigManager GetConfigManager()
 {
     return(ConfigManagerFactory.CreateStorageAccountConfigManager(
                ConfigHelper.ConfigStorageAccountConnectionString));
 }