Example #1
0
        private List <SettingItemViewModel> SettingsView()
        {
            var clientSettingsBlob = (CloudBlockBlob)Session[SKClientSettingsBlob];
            ApplicationClientMetadata clientApp = JsonConvert.DeserializeObject <ApplicationClientMetadata>(clientSettingsBlob.DownloadText());

            Session[SKClientSettings] = clientApp;

            var extraSettingsBlob             = (CloudBlockBlob)Session[SKExtraSettingsBlob];
            ApplicationExtraMetadata extraApp = JsonConvert.DeserializeObject <ApplicationExtraMetadata>(extraSettingsBlob.DownloadText());

            Session[SKExtraSettings] = extraApp;

            return(CreateAppView(clientApp, extraApp));
        }
Example #2
0
        private CollectiveSettingsView CreateCollectiveSettings(ApplicationClientMetadata clientMetadata, ApplicationExtraMetadata extraMetadata, string uniqueStringInUrl)
        {
            var svm = new CollectiveSettingsView
            {
                AzureSubscriptionId                   = extraMetadata.SubscriptionId,
                DecisionType                          = extraMetadata.DecisionType == DecisionType.SingleAction ? DecisionDisplayType.No : DecisionDisplayType.Yes,
                TrainArguments                        = clientMetadata.TrainArguments,
                AzureStorageConnectionString          = ConfigurationManager.AppSettings[ApplicationMetadataStore.AKConnectionString],
                AzureResourceGroupName                = extraMetadata.AzureResourceGroupName,
                ApplicationInsightsInstrumentationKey = ConfigurationManager.AppSettings[ApplicationMetadataStore.AKAppInsightsKey],
                OnlineTrainerAddress                  = ConfigurationManager.AppSettings[ApplicationMetadataStore.AKTrainerURL],
                WebApiAddress                         = $"https://{extraMetadata.AzureResourceGroupName}-webapi-{uniqueStringInUrl}.azurewebsites.net",
                ASAEvalName = extraMetadata.AzureResourceGroupName + "-eval",
                ASAJoinName = extraMetadata.AzureResourceGroupName + "-join",
                EventHubInteractionConnectionString = clientMetadata.EventHubInteractionConnectionString,
                EventHubObservationConnectionString = clientMetadata.EventHubObservationConnectionString,
                ExperimentalUnitDuration            = extraMetadata.ExperimentalUnitDuration,
                SelectedModelId = new SettingBlobListViewModel
                {
                    Items = new List <BlobModelViewModel>()
                    {
                        new BlobModelViewModel
                        {
                            Name = ApplicationSettingConstants.UseLatestModelSetting
                        }
                    },
                    SelectedItem = extraMetadata.ModelId
                },
                IsExplorationEnabled      = clientMetadata.IsExplorationEnabled,
                InitialExplorationEpsilon = clientMetadata.InitialExplorationEpsilon,
                SettingsBlobUri           = extraMetadata.SettingsTokenUri1
            };

            return(svm);
        }
Example #3
0
        private List <SettingItemViewModel> CreateAppView(
            ApplicationClientMetadata clientMetadata,
            ApplicationExtraMetadata extraMetadata)
        {
            string uniqueStringInUrl = Regex.Match(Request.Url.ToString(), ".*mc-(.*).azurewebsites.*").Groups[1].Value;

            CollectiveSettingsView svm = CreateCollectiveSettings(clientMetadata, extraMetadata, uniqueStringInUrl);

            string azureStorageName = Regex.Match(svm.AzureStorageConnectionString, ".*AccountName=(.*);AccountKey.*").Groups[1].Value;

            var nameToValue = svm.GetType().GetProperties()
                              .Select(p => new { Name = p.Name, Value = p.GetValue(svm) });

            var nameToHelpText = typeof(HelpText).GetProperties()
                                 .Where(p => p.PropertyType == typeof(string))
                                 .Select(p => new { HelpText = ((string)p.GetValue(null)).Split(new string[] { " ::: " }, StringSplitOptions.RemoveEmptyEntries).ToList(), Name = p.Name });

            var nameToUrl = new[]
            {
                new { Name = nameof(svm.AzureResourceGroupName), Tooltip = "View Azure Resource Group", Url = $"https://ms.portal.azure.com/#asset/HubsExtension/ResourceGroups/subscriptions/{svm.AzureSubscriptionId}/resourceGroups/{svm.AzureResourceGroupName}" },
                new { Name = nameof(svm.AzureStorageConnectionString), Tooltip = "View Data", Url = $"https://ms.portal.azure.com/#blade/Microsoft_Azure_Storage/ContainersBlade/storageAccountId/%2Fsubscriptions%2F{svm.AzureSubscriptionId}%2FresourceGroups%2F{svm.AzureResourceGroupName}%2Fproviders%2FMicrosoft.Storage%2FstorageAccounts%2F{azureStorageName}" },
                new { Name = nameof(svm.ApplicationInsightsInstrumentationKey), Tooltip = "View Application Logs", Url = $"https://ms.portal.azure.com/#blade/AppInsightsExtension/SearchBlade/ComponentId/%7B%22SubscriptionId%22%3A%22{svm.AzureSubscriptionId}%22%2C%22ResourceGroup%22%3A%22{svm.AzureResourceGroupName}%22%2C%22Name%22%3A%22{svm.AzureResourceGroupName}-appinsights-{uniqueStringInUrl}%22%7D/InitialFilter/%7B%22eventTypes%22%3A%5B4%2C1%2C3%2C5%2C2%2C6%5D%2C%22typeFacets%22%3A%7B%7D%2C%22isPermissive%22%3Afalse%7D/InitialTime/%7B%22durationMs%22%3A43200000%2C%22endTime%22%3Anull%2C%22isInitialTime%22%3Atrue%2C%22grain%22%3A1%7D/InitialQueryText//ConfigurationId/blankSearch%3A" },
                new { Name = nameof(svm.ASAJoinName), Tooltip = "View ASA Join Query", Url = $"https://ms.portal.azure.com/#resource/subscriptions/{svm.AzureSubscriptionId}/resourceGroups/{svm.AzureResourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{svm.ASAJoinName}" },
                new { Name = nameof(svm.ASAEvalName), Tooltip = "View ASA Policy Evaluation Query", Url = $"https://ms.portal.azure.com/#resource/subscriptions/{svm.AzureSubscriptionId}/resourceGroups/{svm.AzureResourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{svm.ASAEvalName}" },
                new { Name = nameof(svm.OnlineTrainerAddress), Tooltip = "Configure Online Trainer", Url = $"https://manage.windowsazure.com/microsoft.onmicrosoft.com#Workspaces/CloudServicesExtension/CloudService/{svm.OnlineTrainerAddress}/configure" }
            };
            var nameToEditable = new[]
            {
                new { Name = nameof(svm.TrainArguments), IsEditable = true },
                new { Name = nameof(svm.IsExplorationEnabled), IsEditable = true },
                new { Name = nameof(svm.InitialExplorationEpsilon), IsEditable = true },
                new { Name = nameof(svm.SelectedModelId), IsEditable = true }
            };
            var nameToSpotLightUrl = new[]
            {
                new { Name = nameof(svm.AzureResourceGroupName), IsSplotlightUrl = true }
            };
            var nameToResettable = new[]
            {
                new { Name = nameof(svm.OnlineTrainerAddress), Resettable = true }
            };
            var settingItems = from nv in nameToValue
                               from nht in nameToHelpText.Where(n => n.Name == nv.Name).DefaultIfEmpty()
                               from nu in nameToUrl.Where(n => n.Name == nv.Name).DefaultIfEmpty()
                               from ne in nameToEditable.Where(n => n.Name == nv.Name).DefaultIfEmpty()
                               from nsl in nameToSpotLightUrl.Where(n => n.Name == nv.Name).DefaultIfEmpty()
                               from nrs in nameToResettable.Where(n => n.Name == nv.Name).DefaultIfEmpty()
                               select new SettingItemViewModel
            {
                Value           = nv.Value,
                DisplayName     = nht?.HelpText[0],
                HelpText        = nht?.HelpText[1],
                IsEditable      = ne?.IsEditable,
                Name            = nv.Name,
                Url             = nu?.Url,
                UrlToolTip      = nu?.Tooltip,
                IsSplotlightUrl = nsl?.IsSplotlightUrl,
                IsResettable    = nrs?.Resettable
            };

            return(settingItems.ToList());
        }
 private CollectiveSettingsView CreateCollectiveSettings(ApplicationClientMetadata clientMetadata, ApplicationExtraMetadata extraMetadata, string uniqueStringInUrl)
 {
     var svm = new CollectiveSettingsView
     {
         ApplicationId = clientMetadata.ApplicationID,
         AzureSubscriptionId = extraMetadata.SubscriptionId,
         DecisionType = extraMetadata.DecisionType,
         TrainFrequency = extraMetadata.TrainFrequency,
         TrainArguments = clientMetadata.TrainArguments,
         AzureStorageConnectionString = ConfigurationManager.AppSettings[ApplicationMetadataStore.AKConnectionString],
         AzureResourceGroupName = extraMetadata.AzureResourceGroupName,
         ApplicationInsightsInstrumentationKey = ConfigurationManager.AppSettings[ApplicationMetadataStore.AKAppInsightsKey],
         OnlineTrainerAddress = $"http://{extraMetadata.AzureResourceGroupName}-trainer-{uniqueStringInUrl}",
         WebApiAddress = $"https://{extraMetadata.AzureResourceGroupName}-webapi-{uniqueStringInUrl}.azurewebsites.net",
         ASAEvalName = extraMetadata.AzureResourceGroupName + "-eval",
         ASAJoinName = extraMetadata.AzureResourceGroupName + "-join",
         EventHubInteractionConnectionString = clientMetadata.EventHubInteractionConnectionString,
         EventHubObservationConnectionString = clientMetadata.EventHubObservationConnectionString,
         ExperimentalUnitDuration = extraMetadata.ExperimentalUnitDuration,
         SelectedModelId = new SettingBlobListViewModel
         {
             Items = new List<BlobModelViewModel>()
             {
                 new BlobModelViewModel
                 {
                     Name = ApplicationSettingConstants.UseLatestModelSetting
                 }
             },
             SelectedItem = extraMetadata.ModelId
         },
         IsExplorationEnabled = clientMetadata.IsExplorationEnabled,
         InitialExplorationEpsilon = clientMetadata.InitialExplorationEpsilon,
         SettingsBlobUri = extraMetadata.SettingsTokenUri1
     };
     return svm;
 }
        private List<SettingItemViewModel> CreateAppView(
            ApplicationClientMetadata clientMetadata,
            ApplicationExtraMetadata extraMetadata)
        {
            string uniqueStringInUrl = Regex.Match(Request.Url.ToString(), ".*mc-(.*).azurewebsites.*").Groups[1].Value;

            CollectiveSettingsView svm = CreateCollectiveSettings(clientMetadata, extraMetadata, uniqueStringInUrl);

            string azureStorageName = Regex.Match(svm.AzureStorageConnectionString, ".*AccountName=(.*);AccountKey.*").Groups[1].Value;

            var nameToValue = svm.GetType().GetProperties()
                .Select(p => new { Name = p.Name, Value = p.GetValue(svm) });

            var nameToHelpText = typeof(HelpText).GetProperties()
                .Where(p => p.PropertyType == typeof(string))
                .Select(p => new { HelpText = ((string)p.GetValue(null)).Split(new string[] { " ::: " }, StringSplitOptions.RemoveEmptyEntries).ToList(), Name = p.Name });

            var nameToUrl = new[]
            {
                new { Name = nameof(svm.AzureResourceGroupName), Tooltip = "View Azure Resource Group", Url = $"https://ms.portal.azure.com/#asset/HubsExtension/ResourceGroups/subscriptions/{svm.AzureSubscriptionId}/resourceGroups/{svm.AzureResourceGroupName}"},
                new { Name = nameof(svm.AzureStorageConnectionString), Tooltip = "View Data", Url = $"https://ms.portal.azure.com/#blade/Microsoft_Azure_Storage/ContainersBlade/storageAccountId/%2Fsubscriptions%2F{svm.AzureSubscriptionId}%2FresourceGroups%2F{svm.AzureResourceGroupName}%2Fproviders%2FMicrosoft.Storage%2FstorageAccounts%2F{azureStorageName}"},
                new { Name = nameof(svm.ApplicationInsightsInstrumentationKey), Tooltip = "View Application Logs", Url = $"https://ms.portal.azure.com/#blade/AppInsightsExtension/SearchBlade/ComponentId/%7B%22SubscriptionId%22%3A%22{svm.AzureSubscriptionId}%22%2C%22ResourceGroup%22%3A%22{svm.AzureResourceGroupName}%22%2C%22Name%22%3A%22{svm.AzureResourceGroupName}-appinsights-{uniqueStringInUrl}%22%7D/InitialFilter/%7B%22eventTypes%22%3A%5B4%2C1%2C3%2C5%2C2%2C6%5D%2C%22typeFacets%22%3A%7B%7D%2C%22isPermissive%22%3Afalse%7D/InitialTime/%7B%22durationMs%22%3A43200000%2C%22endTime%22%3Anull%2C%22isInitialTime%22%3Atrue%2C%22grain%22%3A1%7D/InitialQueryText//ConfigurationId/blankSearch%3A"},
                new { Name = nameof(svm.ASAJoinName), Tooltip = "View ASA Join Query", Url = $"https://ms.portal.azure.com/#resource/subscriptions/{svm.AzureSubscriptionId}/resourceGroups/{svm.AzureResourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{svm.ASAJoinName}"},
                new { Name = nameof(svm.ASAEvalName), Tooltip = "View ASA Policy Evaluation Query", Url = $"https://ms.portal.azure.com/#resource/subscriptions/{svm.AzureSubscriptionId}/resourceGroups/{svm.AzureResourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{svm.ASAEvalName}"},
                new { Name = nameof(svm.OnlineTrainerAddress), Tooltip = "Configure Online Trainer", Url = $"https://manage.windowsazure.com/microsoft.onmicrosoft.com#Workspaces/CloudServicesExtension/CloudService/{svm.OnlineTrainerAddress}/configure"}
            };
            var nameToEditable = new[]
            {
                new { Name = nameof(svm.TrainArguments), IsEditable = true },
                new { Name = nameof(svm.IsExplorationEnabled), IsEditable = true },
                new { Name = nameof(svm.InitialExplorationEpsilon), IsEditable = true },
                new { Name = nameof(svm.SelectedModelId), IsEditable = true }
            };
            var nameToSpotLightUrl = new[]
            {
                new { Name = nameof(svm.AzureResourceGroupName), IsSplotlightUrl = true }
            };
            var nameToResettable = new[]
            {
                new { Name = nameof(svm.OnlineTrainerAddress), Resettable = true }
            };
            var settingItems = from nv in nameToValue
                        from nht in nameToHelpText.Where(n => n.Name == nv.Name).DefaultIfEmpty()
                        from nu in nameToUrl.Where(n => n.Name == nv.Name).DefaultIfEmpty()
                        from ne in nameToEditable.Where(n => n.Name == nv.Name).DefaultIfEmpty()
                        from nsl in nameToSpotLightUrl.Where(n => n.Name == nv.Name).DefaultIfEmpty()
                        from nrs in nameToResettable.Where(n => n.Name == nv.Name).DefaultIfEmpty()
                        select new SettingItemViewModel
                        {
                            Value = nv.Value,
                            DisplayName = nht?.HelpText[0],
                            HelpText = nht?.HelpText[1],
                            IsEditable = ne?.IsEditable,
                            Name = nv.Name,
                            Url = nu?.Url,
                            UrlToolTip = nu?.Tooltip,
                            IsSplotlightUrl = nsl?.IsSplotlightUrl,
                            IsResettable = nrs?.Resettable
                        };

            return settingItems.ToList();
        }