Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "BobIngham"

dotnet core, .net framework 4.6.1, angular, Zero 6.8.0 I would like to move my connection strings to Azure's App Configuration service. I'm not that good down in the magic of how Zero works and I'm scratching my head on how to implement the nuget package Microsoft.Extensions.Configuration.AzureAppConfiguration. Firstly, all advice points to upgrading to .aspnet framework 4.7.1 - am I safe to do this with Zero?

Zero's startup.cs looks as follows:

        public static IWebHostBuilder CreateWebHostBuilder(string[] args)
        {
            return new WebHostBuilder()
                //.CaptureStartupErrors(true)
                //.UseSetting("detailedErrors", "true")
                .UseKestrel(opt => opt.AddServerHeader = false)
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>();
        }

Instructions for ASPNET Core 3 tell me to modify code as follows:

public static IHostBuilder CreateHostBuilder(string[] args) =>
    Host.CreateDefaultBuilder(args)
    .ConfigureWebHostDefaults(webBuilder =>
    webBuilder.ConfigureAppConfiguration((hostingContext, config) =>
    {
        var settings = config.Build();
        config.AddAzureAppConfiguration(settings["ConnectionStrings:AppConfig"]);
    })
    .UseStartup<Startup>());

Or this for .NET Core 2:

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
    WebHost.CreateDefaultBuilder(args)
        .ConfigureAppConfiguration((hostingContext, config) =>
        {
            var settings = config.Build();
            config.AddAzureAppConfiguration(settings["ConnectionStrings:AppConfig"]);
        })
        .UseStartup<Startup>();

Instructions for .NET framework say I should be adding the following to my App.config file but I don't have an App.config file.

<configSections>
    <section name="configBuilders" type="System.Configuration.ConfigurationBuildersSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" restartOnExternalChanges="false" requirePermission="false" />
</configSections>

<configBuilders>
    <builders>
        <add name="MyConfigStore" mode="Greedy" connectionString="${ConnectionString}" type="Microsoft.Configuration.ConfigurationBuilders.AzureAppConfigurationBuilder, Microsoft.Configuration.ConfigurationBuilders.AzureAppConfiguration" />
        <add name="Environment" mode="Greedy" type="Microsoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Environment" />
    </builders>
</configBuilders>

<appSettings configBuilders="Environment,MyConfigStore">
    <add key="AppName" value="Console App Demo" />
    <add key="ConnectionString" value ="Set via an environment variable - for example, dev, test, staging, or production connection string." />
</appSettings>

I'm a little confused and admit to not being the best at this level. Can anyone point me in the right direction for adding Azure App Configuration to Zero 6.8.0?

dotnet-core, angular 6.8.0 Hi Guys, I'm not the best with dependency injection and this one has me scratching my head. I have a CQRS class library used by Zero and also by an Azure function app for Azure Queue Storage. My communicator class looks as follows:

using Microsoft.WindowsAzure.Storage.Queue;
using Nuagecare.AzureQueueLibrary.Messages;
using Nuagecare.AzureQueueLibrary.MessageSerializer;
using System.Threading.Tasks;

namespace Nuagecare.AzureQueueLibrary.QueueConnection
{
    public interface IQueueCommunicator
    {
        T Read<T>(string message);
        Task CreateDefaultDocumentCollectionForTenantAsync<T>(T obj) where T : BaseQueueMessage;

    }
    public class QueueCommunicator : IQueueCommunicator
    {
        private readonly IMessageSerializer _messageSerializer;
        private readonly ICloudQueueClientFactory _cloudQueueClientFactory;

        public QueueCommunicator(IMessageSerializer messageSerializer,
            ICloudQueueClientFactory cloudQueueClientFactory)
        {
            _messageSerializer = messageSerializer;
            _cloudQueueClientFactory = cloudQueueClientFactory;
        }

        public IMessageSerializer MessageSerializer { get; }

        public T Read<T>(string message)
        {
            return _messageSerializer.Deserialize<T>(message);
        }

        public async Task CreateDefaultDocumentCollectionForTenantAsync<T>(T obj) where T : BaseQueueMessage
        {
            var queueReference = _cloudQueueClientFactory.GetClient().GetQueueReference(obj.Route);
            await queueReference.CreateIfNotExistsAsync();

            var serializedMessage = _messageSerializer.Serialize(obj);
            var queueMessage = new CloudQueueMessage(serializedMessage);

            await queueReference.AddMessageAsync(queueMessage);
        }
    }
}

I want to call the CreateDefaultDocumentCollectionForTenantAsync() method from within a Zero application service but I'm having problems injecting the IQueueCommunicator class in my Zero application module. Inside my CQRS AzureQueueLibrary I have a DependencyInjectionRegistry class as follows:

using Microsoft.Extensions.DependencyInjection;
using Nuagecare.AzureQueueLibrary.Infrastructure;
using Nuagecare.AzureQueueLibrary.MessageSerializer;
using Nuagecare.AzureQueueLibrary.QueueConnection;

namespace AzureQueueLibrary.Infrastructure
{
    public static class DependencyInjectionRegistry
    {
        public static IServiceCollection AddAzureQueueLibrary(this IServiceCollection service, string queueConnectionString)
        {
            service.AddSingleton(new QueueConfig(queueConnectionString));
            service.AddSingleton<ICloudQueueClientFactory, CloudQueueClientFactory>();
            service.AddSingleton<IMessageSerializer, JsonMessageSerializer>();
            service.AddTransient<IQueueCommunicator, QueueCommunicator>();
            return service;
        }

    }
}

How do I register this class library in Zero? I thought maybe I could inject into Web.Host Startup.cs:

services.AddAzureQueueLibrary(_appConfiguration["ConnectionStrings:AzureStorage"]);

But AddAzureQueueLibrary is not part of IServiceCollection even after the class library has been added as a dependency. Normally with a class library I would inject to my ApplicationModule as follows:

            Configuration.ReplaceService(typeof(IDocumentProcessor), () =>
            {
                IocManager.IocContainer.Register(
                    Component.For<IDocumentProcessor>()
                        .ImplementedBy<DocumentProcessor>()
                        .LifestyleTransient()
                    );
            });

But this is different not least because it needs _ appConfiguration["ConnectionStrings:AzureStorage"] to be passed along to it when it is injected.

Any help gratefully received!!!!

dotnet core, angular, 6.8.0 An architectural question. My app has to create a set of default documents for each tenant as the tenant is created and it is very heavy on processing. I have implemented a separate project for Azure Storage Queues within the Zero solution, inject it and simply place a request on the queue. I have an Azure function app which polls the queue and creates the documents for the new tenant, all abstracted away from the main processor. So far so good. How do I send a notification through Zero to the user when I'm done? There is no "SendNotification" call in the API, do I need to write one? It's no problem to do so but I only ask in the interest of best practise and you guys always point me in the right direction.

.net core, angular, 6.8.0 I am testing a proof of concept with Syncfusion's document editor and need to convert a .docx file to .sfdt file (syncfusion format) on the server side before editing. My service method looks as follows:

[DontWrapResult(WrapOnError = true)]
public string Import(IFormCollection data)
{
    if (data.Files.Count == 0)
        return null;
    Stream stream = new MemoryStream();
    IFormFile file = data.Files[0];
    int index = file.FileName.LastIndexOf('.');
    string type = index > -1 && index < file.FileName.Length - 1 ?
        file.FileName.Substring(index) : ".docx";
    file.CopyTo(stream);
    stream.Position = 0;

    WordDocument document = WordDocument.Load(stream, GetFormatType(type.ToLower()));
    string sfdt = Newtonsoft.Json.JsonConvert.SerializeObject(document);
    document.Dispose();
    return sfdt;
}

Following Syncfusion's instructions I have a call from angular to same which works fine as follows:

  public loadFile(file: File): void {
    let httpRequest: XMLHttpRequest = new XMLHttpRequest();
    httpRequest.open('POST', 'http://localhost:22742/api/services/app/NcSyncfusionDocumentEditor/Import', true);

    httpRequest.onreadystatechange = () => {
      if (httpRequest.readyState === 4) {
        if (httpRequest.status === 200 || httpRequest.status === 304) {
          this.documentContainer.documentEditor.open(httpRequest.responseText);
          this.documentContainer.documentEditor.isReadOnly = false;
        } else {
          alert('Fail to load the document');
          console.error(httpRequest.response);
        }
      }
    };
    let formData: FormData = new FormData();
    formData.append('files', file);
    httpRequest.send(formData);
  }

My question is how do I convert this call to use the swagger interface - how do I add the form data to the call?

    this._ncDocumentEditorService.import( ?? file ??)
      .subscribe(sfdtDocument => {
        this.documentContainer.documentEditor.open(sfdtDocument);
        this.documentContainer.documentEditor.isReadOnly = false;
      });

.NET Core, Angular, aspnet Framework 4.6.1 - 6.8.1 Having recently upgraded Visual Studio 2019 (Community) to 16.4.0 I am getting the following message on the yellow bar to the top of the page: I don't really want to create bloat with even more Microsoft DLL's, can anyone advise as to whether this should be installed or not? Should it be installed in every project or just in the Web.Host? Has anyone else used it, is it in use at Zero?

At 13:53 my system increases threads by a factor of 3 and there appears to be no reason for it. The logs are clean, there is no increase in requests and no demand from connections. Similarly at the same time there is no pressure on CPU. In this instance I caught the increase and had no option but to restart the API because there would be problems further down the line. Is there any investigation I can carry out before my Application Insights implementation is complete?

Question

dotnet-core, angular, 4.6.1 framework: 6.8.1 Current log4net configuration reads:

<layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%-5level %date [%-5.5thread] %-40.40logger - %message%newline" />
</layout>

Whereas the standard outlines at Apache log4net™ Config Examples reads:

<layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>

Can anyone tell me what [%-5.5thread] and %-40.40logger (note decimal) denotes and what is [%property{NDC}] and why don't we have it? I would like to push my logs to Application Insights and I'm trying to get some more detail on what to capture. Any help anyone? Any pointers to documentation?

It seems I have a similar thread-blocking problem to many others. I started here, Intermittant blocked calls. At the end of this post @karen-hikesupport refers to a newly opened issue so the discussion can be continued, app hang issue.

In his initial reply @ismcagdas states:

Hi @karen-hikesupport Recently, Nito library released a new version and we have upgraded it in ABP Framework. You can try to upgrade your ABP packages to 4.6 and see it if works for you. If not, you can send the dump file to [email protected] and we can also take a look at it.

Along the way I read @Jim Hinnen's excellent post at : App hangs - OnlineClientManager and UserSettingsManager.

My question is, do I simply upgrade abp version to 4.6.0 in my Zero project and this problem will magically go away? I know you guys are capable of magic because I have worked with your systems for a long time. I also prefer the magic route to the dump file analytics route....

When I go to Application Insights for my API (dotnet core2.2 on framework 4.6.1 - Zero 6.8.1) I see outliers in my operations chart. When I drill down I see that they are GET / signalr requests: Here's another image of top 3 operations, the third is my own implementation of signalr which is currently on test in the host with one or two connected clients. The ten failures are inline with a auto-scale out operation today. My log is empty of errors. However, when I go to my tenant home page I notice that the chat functionality is gone. . There are no errors in my console and signalr connects ok:

Where do I start looking?

Question

I have read the notes against this issue in the forum for Application Insights. At one stage @walkerscott states:

we have a solution to this. We save our App Insights Instrumentation Key to AbpSettings and this then gets loaded at startup. We also do something similar for Google Analytics.

We'd be willing to contribute this to AspNetZero repo via PR if the team is interested?

I have followed instructions for implementing Application Insights here: Application Insights for ASP.NET Core applications but I am told by my Azure support guys that we're not getting metrics. In the same forum article mentioned above @mitch states:

A vote from me too. It's been a real pain to try to get it to integrate.

Can anyone shed any light on integration of Application Insights with the Zero framework. For me this is a bit of a show stopper because I want to implement an event hub in Azure to feed my logs through to Datadog or Sumo Logic. Any help gratefully appreciated.

Showing 41 to 50 of 142 entries