Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Access Database using Azure Functions #4437


User avatar
0
amrsaafan created

Hello,

When trying to create Azure Functions that will access domain service at my system, domain service have methods that contact with database layer,

this is Code snippet of Azure function [attachment=2:1i2m5o8o]1.jpg[/attachment:1i2m5o8o]

This is the target method that should return all organizations: [attachment=1:1i2m5o8o]2.jpg[/attachment:1i2m5o8o]

And this is the exception: [attachment=0:1i2m5o8o]3.jpg[/attachment:1i2m5o8o]

there is an issue with the unit of work that we are creating it in the function, but that instance is not propagating down to the domain service like we expect.


6 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team
    1. Does the caller await this method?
    2. Try removing the async Task declaration.

    If the above does not work, please copy-and-paste the full stack trace.

  • User Avatar
    0
    amrsaafan created

    unfortunately , removing the async Task declaration didn't resolve the problem So: the full stack trace.:point_down:

    at Abp.Domain.Uow.UnitOfWorkAttribute.GetUnitOfWorkAttributeOrNull(MemberInfo methodInfo) at Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation) at Castle.DynamicProxy.AbstractInvocation.Proceed() at Castle.Proxies.IRepository1Proxy.GetAll() at NetScribe.Organizations.OrganizationManager.GetAll() in D:\TindallMediaProjects\NetScribe\Trunk-Phase4.1\NetScribe.Core\Organizations\OrganizationManager.cs:line 292 at Castle.Proxies.OrganizationManagerProxy.GetAll_callback() at Castle.Proxies.Invocations.IOrganizationManager_GetAll.InvokeMethodOnTarget() at Castle.DynamicProxy.AbstractInvocation.Proceed() at Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation) at Castle.DynamicProxy.AbstractInvocation.Proceed() at Castle.Proxies.OrganizationManagerProxy.GetAll() at NetScribe.Functions.JobImportFunction.Run(HttpRequestMessage req, TraceWriter log) at lambda_method(Closure , JobImportFunction , Object[] ) at Microsoft.Azure.WebJobs.Host.Executors.TaskMethodInvoker2.InvokeAsync(TReflected instance, Object[] arguments) at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.

  • User Avatar
    0
    aaron created
    Support Team

    That doesn't look like the full stack trace.

  • User Avatar
    0
    alper created
    Support Team

    hi,

    I cannot view images clearly because they are tiny. And as @aaron stated, send the whole error message

  • User Avatar
    0
    amrsaafan created

    Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: JobImportFunction ---> System.NullReferenceException : Object reference not set to an instance of an object. at Abp.Domain.Uow.UnitOfWorkAttribute.GetUnitOfWorkAttributeOrNull(MemberInfo methodInfo) at Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation) at Castle.DynamicProxy.AbstractInvocation.Proceed() at Castle.Proxies.IRepository1Proxy.GetAll() at NetScribe.Organizations.OrganizationManager.GetAll() at D:\TindallMediaProjects\NetScribe\Trunk-Phase4.1\NetScribe.Core\Organizations\OrganizationManager.cs : 292 at Castle.Proxies.OrganizationManagerProxy.GetAll_callback() at Castle.Proxies.Invocations.IOrganizationManager_GetAll.InvokeMethodOnTarget() at Castle.DynamicProxy.AbstractInvocation.Proceed() at Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation) at Castle.DynamicProxy.AbstractInvocation.Proceed() at Castle.Proxies.OrganizationManagerProxy.GetAll() at NetScribe.Functions.JobImportFunction.Run(HttpRequestMessage req,TraceWriter log) at lambda_method(Closure ,JobImportFunction ,Object[] ) at Microsoft.Azure.WebJobs.Host.Executors.TaskMethodInvoker2.InvokeAsync(TReflected instance,Object[] arguments) at async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker2.InvokeAsync[TReflected,TReturnValue](Object instance,Object[] arguments) at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker,ParameterHelper parameterHelper,CancellationTokenSource timeoutTokenSource,CancellationTokenSource functionCancellationTokenSource,Boolean throwOnTimeout,TimeSpan timerInterval,IFunctionInstance instance) at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance,ParameterHelper parameterHelper,TraceWriter traceWriter,CancellationTokenSource functionCancellationTokenSource) at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) End of inner exception at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance,CancellationToken cancellationToken) at Microsoft.Azure.WebJobs.Host.Executors.ExceptionDispatchInfoDelayedException.Throw() at async Microsoft.Azure.WebJobs.JobHost.CallAsync(??) at async Microsoft.Azure.WebJobs.Script.ScriptHost.CallAsync(String method,Dictionary2 arguments,CancellationToken cancellationToken) at async Microsoft.Azure.WebJobs.Script.WebHost.WebScriptHostManager.HandleRequestAsync(FunctionDescriptor function,HttpRequestMessage request,CancellationToken cancellationToken) at async Microsoft.Azure.WebJobs.Script.Host.FunctionRequestInvoker.ProcessRequestAsync(HttpRequestMessage request,CancellationToken cancellationToken,WebScriptHostManager scriptHostManager,WebHookReceiverManager webHookReceiverManager) at async Microsoft.Azure.WebJobs.Script.WebHost.Controllers.FunctionsController.<>c__DisplayClass3_0.<ExecuteAsync>b__0(??) at async Microsoft.Azure.WebJobs.Extensions.Http.HttpRequestManager.ProcessRequestAsync(HttpRequestMessage request,Func`3 processRequestHandler,CancellationToken cancellationToken) at async Microsoft.Azure.WebJobs.Script.WebHost.Controllers.FunctionsController.ExecuteAsync(HttpControllerContext controllerContext,CancellationToken cancellationToken) at async System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken) at async System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken) at async Microsoft.Azure.WebJobs.Script.WebHost.Handlers.WebScriptHostHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken) at async Microsoft.Azure.WebJobs.Script.WebHost.Handlers.SystemTraceHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken) at async System.Web.Http.HttpServer.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)

  • User Avatar
    0
    aaron created
    Support Team

    It looks like you are using a pre-v2.1.0 version of ABP. Try upgrading to v2.3.0.