Example #1
0
 public void SettingAuthentication()
 {
     #region Snippet:SettingAuthentication
     var dataSoure = new SqlServerDataFeedSource("<connection-string>", "<query>")
     {
         Authentication = SqlServerDataFeedSource.AuthenticationType.ManagedIdentity
     };
     #endregion
 }
        public async Task CreateAndDeleteDataFeedAsync()
        {
            string endpoint        = MetricsAdvisorUri;
            string subscriptionKey = MetricsAdvisorSubscriptionKey;
            string apiKey          = MetricsAdvisorApiKey;
            var    credential      = new MetricsAdvisorKeyCredential(subscriptionKey, apiKey);

            var adminClient = new MetricsAdvisorAdministrationClient(new Uri(endpoint), credential);

            string sqlServerConnectionString = SqlServerConnectionString;
            string sqlServerQuery            = SqlServerQuery;

            #region Snippet:CreateDataFeedAsync
            //@@ string sqlServerConnectionString = "<connectionString>";
            //@@ string sqlServerQuery = "<query>";

            var dataFeedName        = "Sample data feed";
            var dataFeedSource      = new SqlServerDataFeedSource(sqlServerConnectionString, sqlServerQuery);
            var dataFeedGranularity = new DataFeedGranularity(DataFeedGranularityType.Daily);

            var dataFeedMetrics = new List <DataFeedMetric>()
            {
                new DataFeedMetric("cost"),
                new DataFeedMetric("revenue")
            };
            var dataFeedDimensions = new List <DataFeedDimension>()
            {
                new DataFeedDimension("category"),
                new DataFeedDimension("city")
            };
            var dataFeedSchema = new DataFeedSchema(dataFeedMetrics)
            {
                DimensionColumns = dataFeedDimensions
            };

            var ingestionStartTime        = DateTimeOffset.Parse("2020-01-01T00:00:00Z");
            var dataFeedIngestionSettings = new DataFeedIngestionSettings(ingestionStartTime);

            var dataFeed = new DataFeed(dataFeedName, dataFeedSource, dataFeedGranularity, dataFeedSchema, dataFeedIngestionSettings);

            Response <string> response = await adminClient.CreateDataFeedAsync(dataFeed);

            string dataFeedId = response.Value;

            Console.WriteLine($"Data feed ID: {dataFeedId}");
            #endregion

            // Only the ID of the data feed is known at this point. You can perform another service
            // call to GetDataFeedAsync or GetDataFeed to get more information, such as status, created
            // time, the list of administrators, or the metric IDs.

            // Delete the created data feed to clean up the Metrics Advisor resource. Do not perform this
            // step if you intend to keep using the data feed.

            await adminClient.DeleteDataFeedAsync(dataFeedId);
        }
Example #3
0
 public void SettingCredentialAuthentication()
 {
     #region Snippet:SettingCredentialAuthentication
     var dataSoure = new SqlServerDataFeedSource("<connection-string>", "<query>")
     {
         Authentication         = SqlServerDataFeedSource.AuthenticationType.ServicePrincipal,
         DataSourceCredentialId = "<credentialId>"
     };
     #endregion
 }
        public void DataFeed()
        {
            var id              = "id";
            var status          = DataFeedStatus.Paused;
            var createdOn       = DateTimeOffset.Parse("2021-01-01T00:00:00Z");
            var creator         = "creator";
            var isAdministrator = true;
            var metricIds       = new Dictionary <string, string>()
            {
                { "key1", "value1" },
                { "key2", "value2" }
            };
            var name                         = "name";
            var dataSource                   = new SqlServerDataFeedSource("query");
            var schema                       = new DataFeedSchema();
            var granularity                  = new DataFeedGranularity(DataFeedGranularityType.Daily);
            var ingestionSettings            = new DataFeedIngestionSettings(DateTimeOffset.UtcNow);
            var description                  = "description";
            var actionLinkTemplate           = "actionLinkTemplate";
            var accessMode                   = DataFeedAccessMode.Public;
            var rollupSettings               = new DataFeedRollupSettings();
            var missingDataPointFillSettings = new DataFeedMissingDataPointFillSettings(DataFeedMissingDataPointFillType.PreviousValue);
            var administrators               = new List <string>()
            {
                "admin1", "admin2"
            };
            var viewers = new List <string>()
            {
                "viewer1", "viewer2"
            };

            var dataFeed = MetricsAdvisorModelFactory.DataFeed(id, status, createdOn, creator, isAdministrator, metricIds, name, dataSource,
                                                               schema, granularity, ingestionSettings, description, actionLinkTemplate, accessMode, rollupSettings, missingDataPointFillSettings,
                                                               administrators, viewers);

            Assert.That(dataFeed.Id, Is.EqualTo(id));
            Assert.That(dataFeed.Status, Is.EqualTo(status));
            Assert.That(dataFeed.CreatedOn, Is.EqualTo(createdOn));
            Assert.That(dataFeed.Creator, Is.EqualTo(creator));
            Assert.That(dataFeed.IsAdministrator, Is.EqualTo(isAdministrator));
            Assert.That(dataFeed.MetricIds, Is.EqualTo(metricIds));
            Assert.That(dataFeed.Name, Is.EqualTo(name));
            Assert.That(dataFeed.DataSource, Is.EqualTo(dataSource));
            Assert.That(dataFeed.Schema, Is.EqualTo(schema));
            Assert.That(dataFeed.Granularity, Is.EqualTo(granularity));
            Assert.That(dataFeed.IngestionSettings, Is.EqualTo(ingestionSettings));
            Assert.That(dataFeed.Description, Is.EqualTo(description));
            Assert.That(dataFeed.ActionLinkTemplate, Is.EqualTo(actionLinkTemplate));
            Assert.That(dataFeed.AccessMode, Is.EqualTo(accessMode));
            Assert.That(dataFeed.RollupSettings, Is.EqualTo(rollupSettings));
            Assert.That(dataFeed.MissingDataPointFillSettings, Is.EqualTo(missingDataPointFillSettings));
            Assert.That(dataFeed.Administrators, Is.EqualTo(administrators));
            Assert.That(dataFeed.Viewers, Is.EqualTo(viewers));
        }