コード例 #1
0
        protected void SetupManagementClient(MockContext context)
        {
            ResourceManagementClient            = GetResourceManagementClient(context);
            HDInsightManagementClient           = GetHDInsightManagementClient(context);
            StorageManagementClient             = GetStorageManagementClient(context);
            OperationalInsightsManagementClient = GetOperationalInsightsManagementClient(context);

            _helper.SetupManagementClients(ResourceManagementClient, HDInsightManagementClient, StorageManagementClient, OperationalInsightsManagementClient);
        }
コード例 #2
0
ファイル: OmsClient.cs プロジェクト: 1RedOne/AzureSDKTest
        private OperationalInsightsManagementClient getOmsClient()
        {
            var credentials = Microsoft.Azure.Management.ResourceManager.Fluent.SdkContext.AzureCredentialsFactory.FromServicePrincipal(logininfo.ClientId, logininfo.ClientSecret, logininfo.TenantId,
                                                                                                                                        Microsoft.Azure.Management.ResourceManager.Fluent.AzureEnvironment.AzureGlobalCloud);
            //var subscriptionId = assignment.ResourceIdentity.Subscription.ToString();
            var client = new OperationalInsightsManagementClient(credentials)
            {
                SubscriptionId = logininfo.SubscriptionId
            };

            return(client);
        }
コード例 #3
0
ファイル: OmsClient.cs プロジェクト: 1RedOne/AzureSDKTest
        public async Task <IEnumerable <Microsoft.Azure.Management.OperationalInsights.Models.Workspace> > GetLogAnalyticsSavedSearch(string token, string searchName)
        {
            var credentials = Microsoft.Azure.Management.ResourceManager.Fluent.SdkContext.AzureCredentialsFactory.FromServicePrincipal(logininfo.ClientId, logininfo.ClientSecret, logininfo.TenantId,
                                                                                                                                        Microsoft.Azure.Management.ResourceManager.Fluent.AzureEnvironment.AzureGlobalCloud);
            //var subscriptionId = assignment.ResourceIdentity.Subscription.ToString();
            var client = new OperationalInsightsManagementClient(credentials)
            {
                SubscriptionId = logininfo.SubscriptionId
            };
            var w = await client.Workspaces.ListByResourceGroupAsync("myTestWorkspaceGroup");

            return(w);
            //var r = client.SavedSearches.ListByWorkspace()
            //client.SavedSearches.GetAsync(assignment.ResourceIdentity.ResourceGroup, )
        }
コード例 #4
0
    public async Async.Task <MonitorSettings> GetMonitorSettings()
    {
        var token  = GetToken();
        var client = new OperationalInsightsManagementClient(new Rest.TokenCredentials(token.Token))
        {
            SubscriptionId = _creds.GetSubscription()
        };

        var customerId = (await client.Workspaces.ListByResourceGroupAsync(_creds.GetBaseResourceGroup()))
                         .Select(w => w.CustomerId)
                         .First();
        var keys = await client.SharedKeys.GetSharedKeysAsync(_creds.GetBaseResourceGroup(), _config.OneFuzzMonitor);

        return(new MonitorSettings(customerId, keys.PrimarySharedKey));
    }
コード例 #5
0
ファイル: LogAnalytics.cs プロジェクト: nharper285/onefuzz
    public async Async.Task <MonitorSettings> GetMonitorSettings()
    {
        string[] scopes = { "https://management.azure.com/.default" };
        var      token  = _creds.GetIdentity().GetToken(new TokenRequestContext(scopes));
        var      client = new OperationalInsightsManagementClient(new Rest.TokenCredentials(token.Token))
        {
            SubscriptionId = _creds.GetSubscription()
        };
        var customerId = (await client.Workspaces.ListByResourceGroupAsync(_creds.GetBaseResourceGroup()))
                         .Select(w => w.CustomerId)
                         .First();
        var keys = await client.SharedKeys.GetSharedKeysAsync(_creds.GetBaseResourceGroup(), _config.OneFuzzMonitor);

        return(new MonitorSettings(customerId, keys.PrimarySharedKey));
    }
コード例 #6
0
        private void SetupManagementClients(RestTestFramework.MockContext context)
        {
            var resourceManagerResourceManagementClient = GetResourceManagerResourceManagementClient(context);

            NetworkManagementClient             = GetNetworkManagementClient(context);
            ComputeManagementClient             = GetComputeManagementClient(context);
            StorageManagementClient             = GetStorageManagementClient(context);
            RedisManagementClient               = GetRedisManagementClient(context);
            OperationalInsightsManagementClient = GetOperationalInsightsManagementClient(context);

            _helper.SetupManagementClients(
                resourceManagerResourceManagementClient,
                NetworkManagementClient,
                ComputeManagementClient,
                StorageManagementClient,
                RedisManagementClient,
                OperationalInsightsManagementClient);
        }
コード例 #7
0
        public async Task <DataTable> DownloadAsync(SearchParameters searchParameters)
        {
            var credentials = SdkContext.AzureCredentialsFactory.FromServicePrincipal(
                _clientId,
                _clientSecret,
                _tenantId,
                AzureEnvironment.AzureGlobalCloud);
            var client = new OperationalInsightsManagementClient(credentials);

            client.SubscriptionId = _subscriptionId;

            var searchResult = await client.Workspaces.GetSearchResultsAsync(_resourceGroup, _workspaceName, searchParameters);

            var tempData = new List <Dictionary <string, string> >();

            _logAnalyticsParser.Parse(searchResult, tempData);
            var dt = _logAnalyticsParser.Transform(tempData);

            return(dt);
        }
コード例 #8
0
        public OperationalInsightsMgmtClient(
            string subscriptionId,
            RestClient restClient
            )
        {
            // We need to initialize new RestClient so that we
            // extract RootHttpHandler and DelegatingHandlers out of it.
            var operationalInsightsRestClient = RestClient
                                                .Configure()
                                                .WithEnvironment(restClient.Environment)
                                                .WithCredentials(restClient.Credentials)
                                                //.WithLogLevel(HttpLoggingDelegatingHandler.Level.BodyAndHeaders)
                                                .Build();

            _operationalInsightsManagementClient = new OperationalInsightsManagementClient(
                restClient.Credentials,
                operationalInsightsRestClient.RootHttpHandler,
                operationalInsightsRestClient.Handlers.ToArray()
                )
            {
                SubscriptionId = subscriptionId
            };
        }
コード例 #9
0
        private void SetupManagementClients(RestTestFramework.MockContext context)
        {
            if (HttpMockServer.Mode == HttpRecorderMode.Record)
            {
                // This allows the use of a particular subscription if the user is associated to several
                // "TEST_CSM_ORGID_AUTHENTICATION=SubscriptionId=<subscription-id>"
                string subId = Environment.GetEnvironmentVariable("TEST_CSM_ORGID_AUTHENTICATION");
                RestTestFramework.TestEnvironment environment = new RestTestFramework.TestEnvironment(connectionString: subId);
                this.MonitorManagementClient             = this.GetInsightsManagementClient(context: context, env: environment);
                this.ResourceManagementClient            = this.GetResourceManagementClient(context: context, env: environment);
                this.StorageManagementClient             = this.GetStorageManagementClient(context: context, env: environment);
                this.ApplicationInsightsClient           = this.GetApplicationInsightsManagementClient(context: context, env: environment);
                this.NetworkManagementClient             = this.GetNetworkManagementClient(context: context, env: environment);
                this.AzureRestClient                     = this.GetAzureRestClient(context: context, env: environment);
                this.OperationalInsightsManagementClient = GetOperationalInsightsManagementClient(context: context, env: environment);
            }
            else if (HttpMockServer.Mode == HttpRecorderMode.Playback)
            {
                this.MonitorManagementClient             = this.GetInsightsManagementClient(context: context, env: null);
                ResourceManagementClient                 = this.GetResourceManagementClient(context: context, env: null);
                StorageManagementClient                  = this.GetStorageManagementClient(context: context, env: null);
                this.ApplicationInsightsClient           = this.GetApplicationInsightsManagementClient(context: context, env: null);
                this.NetworkManagementClient             = this.GetNetworkManagementClient(context: context, env: null);
                this.AzureRestClient                     = this.GetAzureRestClient(context: context, env: null);
                this.OperationalInsightsManagementClient = GetOperationalInsightsManagementClient(context: context, env: null);
            }

            _helper.SetupManagementClients(
                ResourceManagementClient,
                this.MonitorManagementClient,
                StorageManagementClient,
                this.ApplicationInsightsClient,
                this.NetworkManagementClient,
                this.AzureRestClient,
                this.OperationalInsightsManagementClient);
        }