Exemple #1
0
        protected async Task <App> GetAppResource(string subscriptionId, string resourceGroup, string appName, DiagnosticSiteData postBody, DateTime startTime, DateTime endTime)
        {
            string requestId = string.Empty;

            if (this.Request.Headers.TryGetValue(HeaderConstants.RequestIdHeaderName, out StringValues requestIds))
            {
                requestId = requestIds.FirstOrDefault() ?? string.Empty;
            }

            App app = new App(subscriptionId, resourceGroup, appName)
            {
                DefaultHostName                                       = postBody.DefaultHostName,
                Hostnames                                             = postBody.HostNames != null?postBody.HostNames.Select(p => p.Name) : new List <string>(),
                                                      WebSpace        = postBody.WebSpace,
                                                      ScmSiteHostname = postBody.ScmSiteHostname,
                                                      Stamp           = await GetHostingEnvironment(postBody.Stamp.Subscription, postBody.Stamp.ResourceGroup, postBody.Stamp != null?postBody.Stamp.Name : string.Empty, postBody.Stamp, startTime, endTime),
                                                      AppType         = GetApplicationType(postBody.Kind),
                                                      PlatformType    = (!string.IsNullOrWhiteSpace(postBody.Kind) && postBody.Kind.ToLower().Contains("linux")) ? PlatformType.Linux : PlatformType.Windows,
                                                      StackType       = await this._siteService.GetApplicationStack(subscriptionId, resourceGroup, appName, requestId)
            };

            switch (app.Stamp.HostingEnvironmentType)
            {
            case HostingEnvironmentType.V1:
                app.StampType = StampType.ASEV1;
                break;

            case HostingEnvironmentType.V2:
                app.StampType = StampType.ASEV2;
                break;

            default:
                app.StampType = StampType.Public;
                break;
            }

            return(app);
        }
Exemple #2
0
        public async Task <IActionResult> ListDetectors(string subscriptionId, string resourceGroupName, string siteName, [FromBody] DiagnosticSiteData postBody, [FromQuery(Name = "text")] string text = null)
        {
            if (IsPostBodyMissing(postBody))
            {
                postBody = await GetSitePostBody(subscriptionId, resourceGroupName, siteName);
            }

            DateTimeHelper.PrepareStartEndTimeWithTimeGrain(string.Empty, string.Empty, string.Empty, out DateTime startTimeUtc, out DateTime endTimeUtc, out TimeSpan timeGrainTimeSpan, out string errorMessage);
            App app = await GetAppResource(subscriptionId, resourceGroupName, siteName, postBody, startTimeUtc, endTimeUtc);

            return(await base.ListDetectors(app, text));
        }
Exemple #3
0
        public async Task <IActionResult> GetDetector(string subscriptionId, string resourceGroupName, string siteName, string detectorId, [FromBody] DiagnosticSiteData postBody, string startTime = null, string endTime = null, string timeGrain = null, [FromQuery][ModelBinder(typeof(FormModelBinder))] Form form = null)
        {
            if (IsPostBodyMissing(postBody))
            {
                postBody = await GetSitePostBody(subscriptionId, resourceGroupName, siteName);
            }

            if (!DateTimeHelper.PrepareStartEndTimeWithTimeGrain(startTime, endTime, timeGrain, out DateTime startTimeUtc, out DateTime endTimeUtc, out TimeSpan timeGrainTimeSpan, out string errorMessage))
            {
                return(BadRequest(errorMessage));
            }

            App app = await GetAppResource(subscriptionId, resourceGroupName, siteName, postBody, startTimeUtc, endTimeUtc);

            return(await base.GetDetector(app, detectorId, startTime, endTime, timeGrain, form : form));
        }
Exemple #4
0
        public async Task <IActionResult> GetGistAsync(string subscriptionId, string resourceGroupName, string siteName, string gistId, [FromBody] DiagnosticSiteData postBody, string startTime = null, string endTime = null, string timeGrain = null)
        {
            if (IsPostBodyMissing(postBody))
            {
                postBody = await GetSitePostBody(subscriptionId, resourceGroupName, siteName);
            }

            if (!DateTimeHelper.PrepareStartEndTimeWithTimeGrain(startTime, endTime, timeGrain, out DateTime startTimeUtc, out DateTime endTimeUtc, out TimeSpan timeGrainTimeSpan, out string errorMessage))
            {
                return(BadRequest(errorMessage));
            }

            App app = await GetAppResource(subscriptionId, resourceGroupName, siteName, postBody, startTimeUtc, endTimeUtc);

            return(await base.GetGist(app, gistId, startTime, endTime, timeGrain));
        }
Exemple #5
0
 private static bool IsPostBodyMissing(DiagnosticSiteData postBody)
 {
     return(postBody == null || string.IsNullOrWhiteSpace(postBody.Name));
 }
        public async Task <IActionResult> GetInsights(string subscriptionId, string resourceGroupName, string siteName, [FromBody] DiagnosticSiteData postBody, string pesId = null, string supportTopicId = null, string startTime = null, string endTime = null, string timeGrain = null)
        {
            if (postBody == null)
            {
                return(BadRequest("Post Body missing."));
            }

            if (!DateTimeHelper.PrepareStartEndTimeWithTimeGrain(startTime, endTime, timeGrain, out DateTime startTimeUtc, out DateTime endTimeUtc, out TimeSpan timeGrainTimeSpan, out string errorMessage))
            {
                return(BadRequest(errorMessage));
            }

            App app = await GetAppResource(subscriptionId, resourceGroupName, siteName, postBody, startTimeUtc, endTimeUtc);

            return(await base.GetInsights(app, pesId, supportTopicId, startTime, endTime, timeGrain));
        }
        public async Task <IActionResult> ListDetectors(string subscriptionId, string resourceGroupName, string siteName, [FromBody] DiagnosticSiteData postBody)
        {
            if (postBody == null)
            {
                return(BadRequest("Post Body missing."));
            }

            DateTimeHelper.PrepareStartEndTimeWithTimeGrain(string.Empty, string.Empty, string.Empty, out DateTime startTimeUtc, out DateTime endTimeUtc, out TimeSpan timeGrainTimeSpan, out string errorMessage);
            App app = await GetAppResource(subscriptionId, resourceGroupName, siteName, postBody, startTimeUtc, endTimeUtc);

            return(await base.ListDetectors(app));
        }
        protected async Task <App> GetAppResource(string subscriptionId, string resourceGroup, string appName, DiagnosticSiteData postBody, DateTime startTime, DateTime endTime)
        {
            App app = new App(subscriptionId, resourceGroup, appName)
            {
                DefaultHostName                                       = postBody.DefaultHostName,
                Hostnames                                             = postBody.HostNames != null?postBody.HostNames.Select(p => p.Name) : new List <string>(),
                                                      WebSpace        = postBody.WebSpace,
                                                      ScmSiteHostname = postBody.ScmSiteHostname,
                                                      Stamp           = await GetHostingEnvironment(postBody.Stamp.Subscription, postBody.Stamp.ResourceGroup, postBody.Stamp != null?postBody.Stamp.Name : string.Empty, postBody.Stamp, startTime, endTime, postBody.Kind),
                                                      AppType         = GetApplicationType(postBody.Kind),
                                                      PlatformType    = (!string.IsNullOrWhiteSpace(postBody.Kind) && postBody.Kind.ToLower().Contains("linux")) ? PlatformType.Linux : PlatformType.Windows,
                                                      StackType       = StackType.All, //await this._siteService.GetApplicationStack(subscriptionId, resourceGroup, appName, (DataProviderContext)HttpContext.Items[HostConstants.DataProviderContextKey])
                                                      // Not Fetching Stack Information anymore for kusto optimizations. Instead, detectors should look to leverage a gist created for the same.
                                                      Tags = postBody.Tags
            };

            switch (app.Stamp.HostingEnvironmentType)
            {
            case HostingEnvironmentType.V1:
                app.StampType = StampType.ASEV1;
                break;

            case HostingEnvironmentType.V2:
                app.StampType = StampType.ASEV2;
                break;

            default:
                app.StampType = StampType.Public;
                break;
            }

            if (Request.Headers.TryGetValue(HeaderConstants.SubscriptionLocationPlacementId, out StringValues subscriptionLocationPlacementId))
            {
                app.SubscriptionLocationPlacementId = subscriptionLocationPlacementId.FirstOrDefault();
            }
            return(app);
        }
Exemple #9
0
        protected async Task <App> GetAppResource(string subscriptionId, string resourceGroup, string appName, DiagnosticSiteData postBody, DateTime startTime, DateTime endTime)
        {
            App app = new App(subscriptionId, resourceGroup, appName)
            {
                DefaultHostName                                       = postBody.DefaultHostName,
                Hostnames                                             = postBody.HostNames != null?postBody.HostNames.Select(p => p.Name) : new List <string>(),
                                                      WebSpace        = postBody.WebSpace,
                                                      ScmSiteHostname = postBody.ScmSiteHostname,
                                                      Stamp           = await GetHostingEnvironment(postBody.Stamp.Subscription, postBody.Stamp.ResourceGroup, postBody.Stamp != null?postBody.Stamp.Name : string.Empty, postBody.Stamp, startTime, endTime),
                                                      AppType         = GetApplicationType(postBody.Kind),
                                                      PlatformType    = (!string.IsNullOrWhiteSpace(postBody.Kind) && postBody.Kind.ToLower().Contains("linux")) ? PlatformType.Linux : PlatformType.Windows,
                                                      StackType       = await this._siteService.GetApplicationStack(subscriptionId, resourceGroup, appName, (DataProviderContext)HttpContext.Items[HostConstants.DataProviderContextKey])
            };

            switch (app.Stamp.HostingEnvironmentType)
            {
            case HostingEnvironmentType.V1:
                app.StampType = StampType.ASEV1;
                break;

            case HostingEnvironmentType.V2:
                app.StampType = StampType.ASEV2;
                break;

            default:
                app.StampType = StampType.Public;
                break;
            }

            return(app);
        }
Exemple #10
0
 // Method taken from master2 to derive platform type - skipping the logic of Xenon and Hyper-V
 private PlatformType GetPlatformType(DiagnosticSiteData postBody)
 {
     return((!string.IsNullOrWhiteSpace(postBody.Kind) && postBody.Kind.ToLower().Contains("linux")) ? PlatformType.Linux :
            PlatformType.Windows);
 }