While following the beginners' course on MVA I came to know about Application Insights being available for running in local mode. Upon adding the same to my sample project I was surprised to find the activity to be showing 0's (zeros)?
I right clicked the project
Selected Add > Application Insights Telemetry
Upon Application Insights Configuration Page selected Start Free
On the proceeding page I selected the option Or just add SDK to try local only mode at the bottom of page
Ran the application by pressing IIS Express
The Application Insightsbutton I had added on the toolbar didn't show any number of activity
Upon clicking the said button the Application Insights Search page appeared, but with every event/result as 0 (Zero)
While the Immediate Window showing Application Insights Telemetry (unconfigured) at some places.
The Startup file is as:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
namespace FAQ
{
public class Startup
{
public Startup(IConfiguration config)
{
configuration = config;
}
public IConfiguration configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<FAQ_TempDB>(options => options.UseInMemoryDatabase("Some_Name"));
services.AddLogging();
services.AddMvc();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
loggerFactory.AddDebug();
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
}
}
while I have used it on the Create Model in a single CRUD page model as:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using FAQ.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
namespace FAQ.Pages
{
public class CreateModel : PageModel
{
private readonly FAQ_TempDB _TempDB;
private ILogger<CreateModel> Log;
public CreateModel(FAQ_TempDB tempDB, ILogger<CreateModel> log)
{
_TempDB = tempDB;
Log = log;
}
[TempData]
public string xMessage { get; set; }
[BindProperty]
public Worker Worker { get; set; }
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid) {return Page();}
_TempDB.Workers.Add(Worker);
await _TempDB.SaveChangesAsync();
var xMsg = $"Record of {Worker.W_FName} added!";
xMessage = xMsg;
Log.LogCritical(xMsg); //LOG ACTIVITY NOT WORKING ON APP INSIGHTS
return RedirectToPage("/BackToDB");
}
}
public class BackToDBModel : PageModel
{
private readonly FAQ_TempDB _TempDB;
public BackToDBModel(FAQ_TempDB tempDB)
{
_TempDB = tempDB;
}
public IList<Worker> Workers { get; private set; }
[TempData]
public string xMessage { get; set; } //Name should be same as one declared in Create Model
public async Task OnGetAsync()
{
Workers = await _TempDB.Workers.AsNoTracking().ToListAsync();
}
public async Task<IActionResult> OnPostDeleteAsync(int id)
{
var worker = await _TempDB.Workers.FindAsync(id);
if (worker != null)
{
_TempDB.Workers.Remove(worker);
await _TempDB.SaveChangesAsync();
}
return RedirectToPage();
}
}
public class EditModel : PageModel
{
private readonly FAQ_TempDB _TempDB;
public EditModel(FAQ_TempDB tempDB)
{
_TempDB = tempDB;
}
[BindProperty]
public Worker Worker { get; set; }
public async Task<IActionResult> OnGetAsync(int id)
{
Worker = await _TempDB.Workers.FindAsync(id);
if (Worker == null)
{
return RedirectToPage("/BackToDB");
}
return Page();
}
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
_TempDB.Attach(Worker).State = EntityState.Modified;
try
{
await _TempDB.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException ex)
{
throw new Exception($"Worker {Worker.W_FName} Not Found!", ex);
}
return RedirectToPage("/BackToDB");
}
}
}
The app works well on console reflecting the requisite critical portion in red but I don't understand why not on the local mode of Application Insights? Is it necessary to use Azure?
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
I don't find the screenshot to be uploading on this forum. Perhaps never had any reason for doing so earlier. Have tried the Insert/edit image button and inserted the image address in the source textbox but the preview reflects nothing below:
Screenshot attempted to be inserted above reflects the Zeros as numbers for
All, while in your provided image, the same being reflected as 6 in All (1 for Request & 5 for Trace)
I am already using the Visual Studio 2017 (Community).
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
If you get any solution for this issue, it would be appreciated if you could share us it here.
Best Regards,
Edward
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
25 Points
92 Posts
Application Insights Not Running In Local Mode
Dec 26, 2017 08:11 PM|Faraz A. Qureshi|LINK
Hi,
While following the beginners' course on MVA I came to know about Application Insights being available for running in local mode. Upon adding the same to my sample project I was surprised to find the activity to be showing 0's (zeros)?
While the Immediate Window showing Application Insights Telemetry (unconfigured) at some places.
The Startup file is as:
while I have used it on the Create Model in a single CRUD page model as:
The app works well on console reflecting the requisite critical portion in red but I don't understand why not on the local mode of Application Insights? Is it necessary to use Azure?
Please see if any of you experts can help.
Thanks
Contributor
3310 Points
1607 Posts
Re: Application Insights Not Running In Local Mode
Dec 27, 2017 03:12 AM|Edward Z|LINK
Hi Faraz,
>> I was surprised to find the activity to be showing 0's (zeros)?
Could you share us a screen shot about this? Do you mean the red area in image below is zero?
I suggest you upgrade VS to VS 2017 latest version, and try again.
For Application Insights issue, I would suggest you submit an issue below:
# https://github.com/Microsoft/ApplicationInsights-Home/issues
Best Regards,
Edward
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
25 Points
92 Posts
Re: Application Insights Not Running In Local Mode
Dec 27, 2017 04:46 AM|Faraz A. Qureshi|LINK
Thanks for your response Edward.
I don't find the screenshot to be uploading on this forum. Perhaps never had any reason for doing so earlier. Have tried the Insert/edit image button and inserted the image address in the source textbox but the preview reflects nothing below:
Screenshot attempted to be inserted above reflects the Zeros as numbers for All, while in your provided image, the same being reflected as 6 in All (1 for Request & 5 for Trace)
I am already using the Visual Studio 2017 (Community).
Contributor
3310 Points
1607 Posts
Re: Application Insights Not Running In Local Mode
Dec 28, 2017 06:38 AM|Edward Z|LINK
Hi Faraz,
In my option, your issue is more related with Application Insights instead of Asp.net Core.
To be honesty, I am not familiar with AI, I would suggest you try forum below:
#https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=ApplicationInsights
Best Regards,
Edward
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
25 Points
92 Posts
Re: Application Insights Not Running In Local Mode
Dec 28, 2017 07:41 AM|Faraz A. Qureshi|LINK
Thanks Edward,
While I had posted the same on GitHub I have also done on the msdn forum At This Location recommended. Thanks again for all your help and guidance.
However, inconvenience of any sort is regretted.
Contributor
3310 Points
1607 Posts
Re: Application Insights Not Running In Local Mode
Dec 29, 2017 05:45 AM|Edward Z|LINK
Hi Faraz,
If you get any solution for this issue, it would be appreciated if you could share us it here.
Best Regards,
Edward
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.