Currently running : ANZ 9.3
We currently heavily use Azure for our pipeline. We have logic within an Azure Function that does Azure Push Notifications so would love to also send to the web to notify users via AppNotifier here as well.
There is probably a much larger requirment but what is needed to push messages outside of web host? I am battling to access AppNotifier (Object reference).
The FunctionStartup Configuration - where I attempt to DI IAppNotifier? :shrug :
Any help would be appreciated. I am assuming Im misunderstanding a key understanding regarding the signalR notification system and what is possible.
4 Answer(s)
-
0
Hi @devinedon
Does your project contains an ABP Module class which contains the Azure Function ? You need to create a module as explained here https://aspnetboilerplate.com/Pages/Documents/Module-System
-
0
Hey, thanks for the reply
It seems like its still ongoing :/ https://github.com/abpframework/abp/issues/527 With Dependency Injection its now most likely possible for Azure Functions https://docs.microsoft.com/en-us/azure/azure-functions/functions-dotnet-dependency-injection
Do you have any ideas how I could convert my azure function into an ABP Module? Here is my onConfigure so far
`using Microsoft.Azure.Documents.Client; using Microsoft.Azure.Functions.Extensions.DependencyInjection; using Microsoft.Azure.WebJobs.Host.Bindings; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using SynapWare.Configuration; using SynapWare.CosmosDB; using SynapWare.Notifications; using System; using System.Collections.Generic;
[assembly: FunctionsStartup(typeof(SynapWare.AzureFunction.IoT.Startup))] namespace SynapWare.AzureFunction.IoT { public class Startup : FunctionsStartup { private IConfigurationRoot _appConfiguration; private DocumentClient _documentClient;
public override void Configure(IFunctionsHostBuilder builder) { var executioncontextoptions = builder.Services.BuildServiceProvider().GetService<IOptions<ExecutionContextOptions>>().Value; var currentDirectory = executioncontextoptions.AppDirectory; //_appConfiguration = AppConfigurations.Get(Environment.CurrentDirectory); _appConfiguration = AppConfigurations.Get(currentDirectory); var serviceEndpoint = new Uri(_appConfiguration.GetValue<string>("LatestDeviceDataCosmosDb:ServiceEndpoint"), UriKind.Absolute); var authKey = _appConfiguration.GetValue<string>("LatestDeviceDataCosmosDb:authKey"); var databaseName = _appConfiguration.GetValue<string>("LatestDeviceDataCosmosDb:DatabaseName"); var collectionName = _appConfiguration.GetValue<string>("LatestDeviceDataCosmosDb:CollectionName"); var collectionNames = new List<string>(); collectionNames.Add(collectionName); var jsonSer = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Ignore, ContractResolver = new DefaultContractResolver { NamingStrategy = new CamelCaseNamingStrategy() } }; _documentClient = new DocumentClient(serviceEndpoint, authKey, jsonSer); _documentClient.OpenAsync().Wait(); var cosmosDbClientFactory = new CosmosDbClientFactory(databaseName, collectionNames, _documentClient); cosmosDbClientFactory.EnsureDbSetupAsync().Wait(); builder.Services.AddSingleton<ICosmosDbClientFactory>(cosmosDbClientFactory); var connectionString = _appConfiguration.GetValue<string>("NotificationHubSettings:FullAccessConnectionString"); var notificationHubPath = _appConfiguration.GetValue<string>("NotificationHubSettings:NotificationHubName"); var notificationHub = new NotificationHubManager(connectionString, notificationHubPath); builder.Services.AddSingleton<INotificationHubManager>(notificationHub); //IocManager.RegisterAssemblyByConvention(typeof(Startup).GetAssembly()); //builder.Services.AddSignalR(); //builder.Services.AddHttpClient(); ////endpoints.MapHub<AbpCommonHub>("/signalr"); //builder.Services.AddSingleton<INotificationPublisher, NotificationPublisher>(); //builder.Services.AddSingleton<IAppNotifier, AppNotifier>(); } }
} ` Assuming whatever magic will happen here. I need to register IoCManager manually?
EDIT : Following Migrator project at the moment. Hopefully can sneak it into a using
using (var bootstrapper = AbpBootstrapper.Create<ABCModule>())
-
0
Hi,
AspNet Zero is not using https://github.com/abpframework/abp/, it is using https://github.com/aspnetboilerplate/aspnetboilerplate/.
Maybe this issue can help you https://github.com/aspnetboilerplate/aspnetboilerplate/issues/5342
-
0
Got it working :) Like I stated in previous comment, answer lies within the migrator project. If anyone wants me to post some sample code let me know and I will do that.