Base solution for your next web application
Open Closed

Serverless Services #5094


User avatar
0
adm.zepp created

Hi,

We just got an ASP.NET Zero license. We would like to know if there is any use case of ASP.NET Zero backend being deployed to serverless services, such as (but not limited to) Amazon AWS Lambda.

When it comes to AWS, we could see that most people use EC2 instances. When it comes to Azure, people also tend to use a similar approach. We also read in the presentation "ASP.NET_ZERO_OVERVIEW_2018_FEB.pptx" that ASP.NET Zero was tested on Azure and AWS using PAAS.

Do you have any idea of the viability of using a serverless environment?

We're considering here Angular 5 + ASP.NET Core.

Thanks in advance.

Best regards.


15 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @adm.zepp,

    We haven't tested AspNet Zero in Amazon AWS Lambda. If you have any problems regarding to this, we can try to help.

  • User Avatar
    0
    adm.zepp created

    Hi @ismcagdas

    Thanks for the reply.

    We may give it a shot and I appreciate your help. Do you forsee any impediment for this task?

    Regards.

  • User Avatar
    0
    ismcagdas created
    Support Team

    @adm.zepp,

    I'm not familiar with Amazon AWS Lambda but it is like Azure functions I guess. If so, there shouldn't be a problem.

  • User Avatar
    0
    adm.zepp created

    Hi @ismcagdas

    We'll give it a try then. I'll keep you informed on the results.

    Thank you again.

  • User Avatar
    0
    velu created

    Hi @adm.zepp,

    Any luck in your testing of AspNet Zero in Amazon AWS Lambda.

  • User Avatar
    0
    adm.zepp created

    Hi @ismcagdas

    Sorry for the delay. Only in the last two days were we able to really run some tests.

    Well, the steps we took were:

    1- Check and study as many online resources as we could find related to .Net in AWS Lambda 2- Study the templates offered by AWS Toolkit for Visual Studio for web applications and web API applications in .Net and AWS Lamda 3- Adapt ASP.NET Zero Visual Studio web Solution (the backend) to be deployed to AWS Lambda 4- Deploy the Web.Host project to AWS Lambda (based on the above resources and ASP.NET Zero documentation) 5- Run some tests

    Some references used (other than the templates offered by AWS Toolkit for Visual Studio):

    • <a class="postlink" href="https://aws.amazon.com/pt/blogs/developer/serverless-asp-net-core-2-0-applications/">https://aws.amazon.com/pt/blogs/develop ... lications/</a>
    • <a class="postlink" href="https://aws.amazon.com/pt/blogs/developer/aws-serverless-applications-in-visual-studio/">https://aws.amazon.com/pt/blogs/develop ... al-studio/</a>
    • <a class="postlink" href="https://aws.amazon.com/pt/blogs/developer/running-serverless-asp-net-core-web-apis-with-amazon-lambda/">https://aws.amazon.com/pt/blogs/develop ... on-lambda/</a>

    In step 3, the changes made to the solution were:

    • In project Web.Host:

      • Replaced all the package references to Microsoft.AspNetCore.<Something> with just Microsoft.AspNetCore.All. This is recommended by Amazon, so that all ASP.NET Core packages are available to the application and are not supposedly added to the deployment package because they are already available in AWS Lambda (<a class="postlink" href="https://aws.amazon.com/pt/blogs/developer/serverless-asp-net-core-2-0-applications/">https://aws.amazon.com/pt/blogs/develop ... lications/</a>). The same goes for all the package references to Microsoft.Extensions.<Something>
      • Added package reference to Amazon.Lambda.AspNetCoreServer
      • Added .Net CLI tool reference to Amazon.Lambda.Tools
      • Added property GenerateRuntimeConfigurationFiles (with value "true")
      • Renamed file Program.cs to LocalEntryPoint.cs. The content remained the same. This is for running the project locallly and this worked fine (when tested locally)
      • Created file LambdaEntryPoint.cs in the Startup folder. This one implements a class that is actually the entrypoint of the application when it's run in the AWS Lambda environment. Basically it does the same thing as LocalEntryPoint.cs, but without configuring Kestrel or IIS integration. It basically configures the Startup class
      • Created file serverless.template in the root of the Web.Host project. This file contains the template used by AWS CloudFormation to configure Amazon API Gateway to expose the Lambda function running ASP.NET Core to an HTTP endpoint. Among some other things, it tells AWS Lambda where to find the handler for the lambda function (which is actually a method inherited by LambdaEntryPoint class)
      • Created file aws-lambda-tools-defaults.json in the root of the Web.Host project. It keeps some configuration used during the deployment process
      • Changed file appsettings.production.json according to the URL endpoints provided by Amazon (database and application)
    • In project Web.Core:

      • Replaced all the package references to Microsoft.AspNetCore.<Something> and Microsoft.Extensions.<Something> with just Microsoft.AspNetCore.All, for the same reasons described earlier

    In short, we were able to deploy the Web.Host project to AWS Lambda with no problems (apparentely). Not a single line of error during steps 1 to 4. We tested the application locally in order to check if all the modification made had had some kind of consequence to the application, but apparentely nothing bad happened. It works normally.

    In step 4, we used a publishing method provided by AWS Toolkit for Visual Studio, so it's a pretty straightforward way of deploying the application to AWS Lambda. We just right click on the Web.Host project, choose "Publish to AWS Lambda" from the context menu, provide some information like authentication keys and hit "Publish". No errors occurred during the half a dozen times we performed this operation during our tests. AWS Lambda accepted the project as a legitimate AWS Lambda ASP.NET Core project.

    We have to point out that previouslly to all this we had configured ASP.NET Zero to use MySQL and not SQL Server, but all is working fine so far after we moved to MySQL. We're using AWS RDS to host the database.

    Now, in step 5, when trying to hit the URL endpoint of the application in the browser, we received the following error:

    {"message": "Internal server error"}

    Then we decided to try and run a test directly from AWS Lambda. When we do this, we can see that AWS Lambda was able to find the handler (LambdaEntryPoint) correctly and was able to trigger the configuration performed in the Startup class. And the error occurs in the following line (the full stack trace is further in this message):

    app.UseAbp(options => { options.UseAbpRequestLocalization = false; //used below: UseAbpRequestLocalization });

    If we comment out the line above, another error occurs in the following line:

    app.UseMvc(routes => { routes.MapRoute( name: "defaultWithArea", template: "{area}/{controller=Home}/{action=Index}/{id?}");

    routes.MapRoute(
        name: "default",
        template: "{controller=Home}/{action=Index}/{id?}");
    

    });

    We did this last thing just for testing purposes. We knew that another error would occur, since we commented out an important part of the application. We just wanted to see where the application initialization would stop again. That's why we are not sending the stack trace (but we can, if you find usefull. Tha main message was: "No component for supporting the service Abp.Localization.ILanguageManager was found").

    In one of the tests, we added some lines to the Configure method of the Startup class, just before it called app.UseAbp(). We wanted to be sure that the application was able to communicate whith the database and it turned out it was. The lines we added for this piece of testing were:

    System.Data.Common.DbConnection connection = new MySql.Data.MySqlClient .MySqlConnection(_appConfiguration.GetConnectionString("Default")); connection.Open();

    Well, the full stack trace of the original error (call to app.UseAbp) is:

    { "errorType": "LambdaException", "errorMessage": "An exception was thrown when the constructor for type 'ZeppIT.ZeppPlatformTest.Web.Startup.LambdaEntryPoint' was invoked. Check inner exception for more details.", "cause": { "errorType": "TargetInvocationException", "errorMessage": "Exception has been thrown by the target of an invocation.", "stackTrace": [ "at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor)", "at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)", "at System.Activator.CreateInstance(Type type, Boolean nonPublic)", "at System.Activator.CreateInstance(Type type)" ], "cause": { "errorType": "ComponentActivatorException", "errorMessage": "ComponentActivator: could not instantiate Abp.AspNetZeroCore.Licensing.AspNetZeroLicenseChecker", "stackTrace": [ "at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstanceCore(ConstructorCandidate constructor, Object[] arguments, Type implType)", "at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstance(CreationContext context, ConstructorCandidate constructor, Object[] arguments)", "at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context)", "at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden)", "at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, Boolean trackedExternally)", "at Castle.MicroKernel.Lifestyle.SingletonLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy)", "at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)", "at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)", "at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, IDictionary additionalArguments, IReleasePolicy policy)", "at Castle.Windsor.WindsorContainer.ResolveT", "at Abp.Dependency.IocResolverExtensions.ResolveAsDisposable[T](IIocResolver iocResolver)", "at Abp.AspNetZeroCore.AbpAspNetZeroCoreModule.PostInitialize()", "at System.Collections.Generic.List1.ForEach(Action1 action)", "at Abp.AbpBootstrapper.Initialize()", "at Abp.AspNetCore.AbpApplicationBuilderExtensions.InitializeAbp(IApplicationBuilder app)", "at Abp.AspNetCore.AbpApplicationBuilderExtensions.UseAbp(IApplicationBuilder app, Action1 optionsAction)", "at ZeppIT.ZeppPlatformTest.Web.Startup.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) in C:\\Users\\pedro\\Desktop\\ZeppPlatformTest-20180510-core-angular-core2.0\\ZeppPlatformTest\\aspnet-core\\src\\ZeppIT.ZeppPlatformTest.Web.Host\\Startup\\Startup.cs:line 148", "--- End of stack trace from previous location where exception was thrown ---", "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()", "at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)", "at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder)", "at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()", "at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()", "at Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction..ctor()" ], "cause": { "errorType": "Exception", "errorMessage": "Could not instantiate Abp.AspNetZeroCore.Licensing.AspNetZeroLicenseChecker.", "stackTrace": [ "at Castle.Core.Internal.ReflectionUtil.Instantiate[TBase](Type subtypeofTBase, Object[] ctorArgs)", "at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstanceCore(ConstructorCandidate constructor, Object[] arguments, Type implType)" ], "cause": { "errorType": "TargetInvocationException", "errorMessage": "Exception has been thrown by the target of an invocation.", "stackTrace": [ "at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)", "at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)", "at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)", "at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)", "at System.Activator.CreateInstance(Type type, Object[] args)", "at Castle.Core.Internal.ReflectionUtil.Instantiate[TBase](Type subtypeofTBase, Object[] ctorArgs)" ], "cause": { "errorType": "NetworkInformationException", "errorMessage": "An error was encountered while querying information from the operating system.", "stackTrace": [ "at System.Net.NetworkInformation.LinuxNetworkInterface.GetLinuxNetworkInterfaces()", "at Abp.AspNetZeroCore.Licensing.AspNetZeroLicenseChecker.JjhdcEzTqX0Pb8CWw9()", "at Abp.AspNetZeroCore.Licensing.AspNetZeroLicenseChecker.GetUniqueComputerId()", "at Abp.AspNetZeroCore.Licensing.AspNetZeroLicenseChecker.ddN1X5gXc6V2AWopEX()", "at Abp.AspNetZeroCore.Licensing.AspNetZeroLicenseChecker..ctor(AspNetZeroConfiguration configuration, IAbpZeroConfig abpZeroConfig, String configFilePath)" ], "cause": { "errorType": "AggregateException", "errorMessage": "One or more errors occurred. (Could not find a part of the path '/sys/class/net/lo/mtu'.) (Could not find a part of the path '/sys/class/net/vinternal_1/mtu'.) (Could not find a part of the path '/sys/class/net/vtarget_1/mtu'.) (Could not find a part of the path '/sys/class/net/lo/mtu'.) (Could not find a part of the path '/sys/class/net/vinternal_1/mtu'.) (Could not find a part of the path '/sys/class/net/vtarget_1/mtu'.)", "cause": { "errorType": "DirectoryNotFoundException", "errorMessage": "Could not find a part of the path '/sys/class/net/lo/mtu'.", "stackTrace": [ "at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func2 errorRewriter)", "at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)", "at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)", "at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)", "at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks)", "at System.IO.File.InternalReadAllText(String path, Encoding encoding)", "at System.IO.File.ReadAllText(String path)", "at System.Net.NetworkInformation.StringParsingHelpers.ParseRawIntFile(String filePath)", "at System.Net.NetworkInformation.LinuxIPv4InterfaceProperties.GetMtu()", "at System.Net.NetworkInformation.LinuxIPv4InterfaceProperties..ctor(LinuxNetworkInterface linuxNetworkInterface)", "at System.Net.NetworkInformation.LinuxIPInterfaceProperties..ctor(LinuxNetworkInterface lni)", "at System.Net.NetworkInformation.LinuxNetworkInterface..ctor(String name)", "at System.Net.NetworkInformation.LinuxNetworkInterface.GetOrCreate(Dictionary2 interfaces, String name)", "at System.Net.NetworkInformation.LinuxNetworkInterface.<>c__DisplayClass5_0.<GetLinuxNetworkInterfaces>b__2(String name, LinkLayerAddressInfo* llAddr)" ] }, "causes": [ { "errorType": "DirectoryNotFoundException", "errorMessage": "Could not find a part of the path '/sys/class/net/lo/mtu'.", "stackTrace": [ "at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func2 errorRewriter)", "at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)", "at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)", "at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)", "at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks)", "at System.IO.File.InternalReadAllText(String path, Encoding encoding)", "at System.IO.File.ReadAllText(String path)", "at System.Net.NetworkInformation.StringParsingHelpers.ParseRawIntFile(String filePath)", "at System.Net.NetworkInformation.LinuxIPv4InterfaceProperties.GetMtu()", "at System.Net.NetworkInformation.LinuxIPv4InterfaceProperties..ctor(LinuxNetworkInterface linuxNetworkInterface)", "at System.Net.NetworkInformation.LinuxIPInterfaceProperties..ctor(LinuxNetworkInterface lni)", "at System.Net.NetworkInformation.LinuxNetworkInterface..ctor(String name)", "at System.Net.NetworkInformation.LinuxNetworkInterface.GetOrCreate(Dictionary2 interfaces, String name)", "at System.Net.NetworkInformation.LinuxNetworkInterface.<>c__DisplayClass5_0.<GetLinuxNetworkInterfaces>b__2(String name, LinkLayerAddressInfo* llAddr)" ] }, { "errorType": "DirectoryNotFoundException", "errorMessage": "Could not find a part of the path '/sys/class/net/vinternal_1/mtu'.", "stackTrace": [ "at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func2 errorRewriter)", "at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)", "at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)", "at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)", "at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks)", "at System.IO.File.InternalReadAllText(String path, Encoding encoding)", "at System.IO.File.ReadAllText(String path)", "at System.Net.NetworkInformation.StringParsingHelpers.ParseRawIntFile(String filePath)", "at System.Net.NetworkInformation.LinuxIPv4InterfaceProperties.GetMtu()", "at System.Net.NetworkInformation.LinuxIPv4InterfaceProperties..ctor(LinuxNetworkInterface linuxNetworkInterface)", "at System.Net.NetworkInformation.LinuxIPInterfaceProperties..ctor(LinuxNetworkInterface lni)", "at System.Net.NetworkInformation.LinuxNetworkInterface..ctor(String name)", "at System.Net.NetworkInformation.LinuxNetworkInterface.GetOrCreate(Dictionary2 interfaces, String name)", "at System.Net.NetworkInformation.LinuxNetworkInterface.<>c__DisplayClass5_0.<GetLinuxNetworkInterfaces>b__2(String name, LinkLayerAddressInfo* llAddr)" ] }, { "errorType": "DirectoryNotFoundException", "errorMessage": "Could not find a part of the path '/sys/class/net/vtarget_1/mtu'.", "stackTrace": [ "at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func2 errorRewriter)", "at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)", "at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)", "at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)", "at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks)", "at System.IO.File.InternalReadAllText(String path, Encoding encoding)", "at System.IO.File.ReadAllText(String path)", "at System.Net.NetworkInformation.StringParsingHelpers.ParseRawIntFile(String filePath)", "at System.Net.NetworkInformation.LinuxIPv4InterfaceProperties.GetMtu()", "at System.Net.NetworkInformation.LinuxIPv4InterfaceProperties..ctor(LinuxNetworkInterface linuxNetworkInterface)", "at System.Net.NetworkInformation.LinuxIPInterfaceProperties..ctor(LinuxNetworkInterface lni)", "at System.Net.NetworkInformation.LinuxNetworkInterface..ctor(String name)", "at System.Net.NetworkInformation.LinuxNetworkInterface.GetOrCreate(Dictionary2 interfaces, String name)", "at System.Net.NetworkInformation.LinuxNetworkInterface.<>c__DisplayClass5_0.<GetLinuxNetworkInterfaces>b__2(String name, LinkLayerAddressInfo* llAddr)" ] }, { "errorType": "DirectoryNotFoundException", "errorMessage": "Could not find a part of the path '/sys/class/net/lo/mtu'.", "stackTrace": [ "at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func2 errorRewriter)", "at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)", "at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)", "at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)", "at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks)", "at System.IO.File.InternalReadAllText(String path, Encoding encoding)", "at System.IO.File.ReadAllText(String path)", "at System.Net.NetworkInformation.StringParsingHelpers.ParseRawIntFile(String filePath)", "at System.Net.NetworkInformation.LinuxIPv4InterfaceProperties.GetMtu()", "at System.Net.NetworkInformation.LinuxIPv4InterfaceProperties..ctor(LinuxNetworkInterface linuxNetworkInterface)", "at System.Net.NetworkInformation.LinuxIPInterfaceProperties..ctor(LinuxNetworkInterface lni)", "at System.Net.NetworkInformation.LinuxNetworkInterface..ctor(String name)", "at System.Net.NetworkInformation.LinuxNetworkInterface.GetOrCreate(Dictionary2 interfaces, String name)", "at System.Net.NetworkInformation.LinuxNetworkInterface.<>c__DisplayClass5_0.<GetLinuxNetworkInterfaces>b__0(String name, IpAddressInfo* ipAddr, IpAddressInfo* maskAddr)" ] }, { "errorType": "DirectoryNotFoundException", "errorMessage": "Could not find a part of the path '/sys/class/net/vinternal_1/mtu'.", "stackTrace": [ "at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func2 errorRewriter)", "at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)", "at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)", "at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)", "at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks)", "at System.IO.File.InternalReadAllText(String path, Encoding encoding)", "at System.IO.File.ReadAllText(String path)", "at System.Net.NetworkInformation.StringParsingHelpers.ParseRawIntFile(String filePath)", "at System.Net.NetworkInformation.LinuxIPv4InterfaceProperties.GetMtu()", "at System.Net.NetworkInformation.LinuxIPv4InterfaceProperties..ctor(LinuxNetworkInterface linuxNetworkInterface)", "at System.Net.NetworkInformation.LinuxIPInterfaceProperties..ctor(LinuxNetworkInterface lni)", "at System.Net.NetworkInformation.LinuxNetworkInterface..ctor(String name)", "at System.Net.NetworkInformation.LinuxNetworkInterface.GetOrCreate(Dictionary2 interfaces, String name)", "at System.Net.NetworkInformation.LinuxNetworkInterface.<>c__DisplayClass5_0.<GetLinuxNetworkInterfaces>b__0(String name, IpAddressInfo* ipAddr, IpAddressInfo* maskAddr)" ] }, { "errorType": "DirectoryNotFoundException", "errorMessage": "Could not find a part of the path '/sys/class/net/vtarget_1/mtu'.", "stackTrace": [ "at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func2 errorRewriter)", "at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)", "at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)", "at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)", "at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks)", "at System.IO.File.InternalReadAllText(String path, Encoding encoding)", "at System.IO.File.ReadAllText(String path)", "at System.Net.NetworkInformation.StringParsingHelpers.ParseRawIntFile(String filePath)", "at System.Net.NetworkInformation.LinuxIPv4InterfaceProperties.GetMtu()", "at System.Net.NetworkInformation.LinuxIPv4InterfaceProperties..ctor(LinuxNetworkInterface linuxNetworkInterface)", "at System.Net.NetworkInformation.LinuxIPInterfaceProperties..ctor(LinuxNetworkInterface lni)", "at System.Net.NetworkInformation.LinuxNetworkInterface..ctor(String name)", "at System.Net.NetworkInformation.LinuxNetworkInterface.GetOrCreate(Dictionary`2 interfaces, String name)", "at System.Net.NetworkInformation.LinuxNetworkInterface.<>c__DisplayClass5_0.

    In another place of the AWS console, we found this other piece of error, which was presented at the same time the stack trace above.

    .Internal.WebHost.BuildApplication() at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction..ctor() Could not instantiate Abp.AspNetZeroCore.Licensing.AspNetZeroLicenseChecker.: Exception at Castle.Core.Internal.ReflectionUtil.Instantiate[TBase](Type subtypeofTBase, Object[] ctorArgs) at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstanceCore(ConstructorCandidate constructor, Object[] arguments, Type implType) Exception has been thrown by the target of an invocation.: TargetInvocationException at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at System.Activator.CreateInstance(Type type, Object[] args) at Castle.Core.Internal.ReflectionUtil.Instantiate[TBase](Type subtypeofTBase, Object[] ctorArgs) An error was encountered while querying information from the operating system.: NetworkInformationException at System.Net.NetworkInformation.LinuxNetworkInterface.GetLinuxNetworkInterfaces() at Abp.AspNetZeroCore.Licensing.AspNetZeroLicenseChecker.JjhdcEzTqX0Pb8CWw9() at Abp.AspNetZeroCore.Licensing.AspNetZeroLicenseChecker.GetUniqueComputerId() at Abp.AspNetZeroCore.Licensing.AspNetZeroLicenseChecker.ddN1X5gXc6V2AWopEX() at Abp.AspNetZeroCore.Licensing.AspNetZeroLicenseChecker..ctor(AspNetZeroConfiguration configuration, IAbpZeroConfig abpZeroConfig, String configFilePath) One or more errors occurred. (Could not find a part of the path '/sys/class/net/lo/mtu'.) (Could not find a part of the path '/sys/class/net/vinternal_1/mtu'.) (Could not find a part of the path '/sys/class/net/vtarget_1/mtu'.) (Could not find a part of the path '/sys/class/net/lo/mtu'.) (Could not find a part of the path '/sys/class/net/vinternal_1/mtu'.) (Could not find a part of the path '/sys/class/net/vtarget_1/mtu'.): AggregateException Could not find a part of the path '/sys/class/net/lo/mtu'.: DirectoryNotFoundException at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func2 errorRewriter) at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks) at System.IO.File.InternalReadAllText(String path, Encoding encoding) at System.IO.File.ReadAllText(String path) at System.Net.NetworkInformation.StringParsingHelpers.ParseRawIntFile(String filePath) at System.Net.NetworkInformation.LinuxIPv4InterfaceProperties.GetMtu() at System.Net.NetworkInformation.LinuxIPv4InterfaceProperties..ctor(LinuxNetworkInterface linuxNetworkInterface) at System.Net.NetworkInformation.LinuxIPInterfaceProperties..ctor(LinuxNetworkInterface lni) at System.Net.NetworkInformation.LinuxNetworkInterface..ctor(String name) at System.Net.NetworkInformation.LinuxNetworkInterface.GetOrCreate(Dictionary2 interfaces, String name) at System.Net.NetworkInformation.LinuxNetworkInterface.<>c__DisplayClass5_0.

    END RequestId: 244776bb-5d2b-11e8-957c-6148ef7fcacc REPORT RequestId: 244776bb-5d2b-11e8-957c-6148ef7fcacc Duration: 200.64 ms Billed Duration: 300 ms Memory Size: 512 MB Max Memory Used: 219 MB

    Do you have any idea of what is going on? It seems to be a problem while the application is trying to access a certain file in order to validate the license. I checked the DLL files that were uploaded during the publishing process and all the ABP and other DLL files were copied to the AWS Lambda.

    FYI: we used ASP.NET Zero with ASP.NET Core and .Net Core 2.0 during the tests.

    Thank you.

    Regards.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @adm.zepp,

    Normally license check must not be done for deployed applications, probably there is a bug in our license nuget packages. Could you update nuget packages below and try again ?

    • <a class="postlink" href="https://www.nuget.org/packages/Abp.AspNetZeroCore/">https://www.nuget.org/packages/Abp.AspNetZeroCore/</a>
    • <a class="postlink" href="https://www.nuget.org/packages/Abp.AspNetZeroCore.Web/">https://www.nuget.org/packages/Abp.AspNetZeroCore.Web/</a>
  • User Avatar
    0
    adm.zepp created

    Hi @ismcagdas

    Thank you for the tip. That error is no longer happening. Apparentely the Startup class is being able to initialize with no problems.

    But, when we try to send a request to some API, we're getting a timeout. For example, if we hit:

    <a class="postlink" href="https://mk1zwuo7a2.execute-api.sa-east-1.amazonaws.com/Prod/api/services/app/AuditLog/GetAuditLogs?StartDate=05%2F22%2F2018&EndDate=05%2F22%2F2018">https://mk1zwuo7a2.execute-api.sa-east- ... F22%2F2018</a>

    We get this error:

    {"message": "Endpoint request timed out"}

    The error is actually the same for every request we send to the server. When looking for some logs in AWS Lambda, some messages are shown. For example, the text below appears repeatedly in the logs:

    log4net:ERROR Could not create Appender [RollingFileAppender] of type [log4net.Appender.RollingFileAppender]. Reported error follows. System.IO.IOException: The system cannot open the device or file specified.

    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.Threading.Mutex.MutexTryCodeHelper.MutexTryCode(Object userData) at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) at System.Threading.Mutex.CreateMutexWithGuaranteedCleanup(Boolean initiallyOwned, String name, Boolean& createdNew, SECURITY_ATTRIBUTES secAttrs) at log4net.Appender.RollingFileAppender.ActivateOptions() at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement appenderElement) log4net:ERROR Appender named [RollingFileAppender] not found. [Warning] Microsoft.AspNetCore.DataProtection.Repositories.EphemeralXmlRepository: Using an in-memory repository. Keys will not be persisted to storage. [Warning] Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager: Neither user profile nor HKLM registry available. Using an ephemeral key repository. Protected data will be unavailable when application exits. [Information] Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager: Creating key {8f2f7078-9f7c-462b-9359-397725e92a46} with creation date 2018-05-23 14:23:20Z, activation date 2018-05-23 14:23:20Z, and expiration date 2018-08-21 14:23:20Z. [Warning] Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager: No XML encryptor configured. Key {8f2f7078-9f7c-462b-9359-397725e92a46} may be persisted to storage in unencrypted form.

    We're going to try and figure it out and keep you informed. Of course, if you have any suggestions, we would appretiate them.

    Thank you again!

    Regards.

  • User Avatar
    0
    adm.zepp created

    Hi again @ismcagdas

    Just to give you a feedback:

    We just temporaraly disabled logging and the log4net error stopped. Actually, no error messages are being written to AWS logs, just information and warning level messages.

    But we still get the timeout. We're performing some other testes here and will keep you informed.

    Best regards.

  • User Avatar
    0
    adm.zepp created

    Hi @ismcagdas (yet again)

    We made a "little" mistake in our serverless.template file, used by AWS CloudFormation to orchestrate the creation and deployment of the Lambda Function. We were using an option for serving razor pages and not actual API methods. After we changed that, we hit:

    <a class="postlink" href="https://mk1zwuo7a2.execute-api.sa-east-1.amazonaws.com/Prod/api/services/app/AuditLog/GetAuditLogs?StartDate=05%2F22%2F2018&EndDate=05%2F22%2F2018">https://mk1zwuo7a2.execute-api.sa-east- ... F22%2F2018</a>

    And guess what? It sent us back the right answer:

    {"result":null,"targetUrl":null,"success":false,"error":{"code":0,"message":"Current user did not login to the application!","details":null,"validationErrors":null},"unAuthorizedRequest":true,"__abp":true}

    Then we accessed the Angular application (configured to use the AWS Lambda endpoint in the remoteServiceBaseUrl property of appconfig.json) and it is working correctly apparently.

    We had uploaded the production build of the Angular application to AWS S3, but unfortunately we had to delete most of the files, which means we can't test the communication between the frontend and backend when both are in Amazon, at least not right now. We wanted to do so just to check the performance. When we have the chance, we'll do it and tell you what happened. My guess is it's gonna perform well, since the performance of the communication between the Angular application running in my machine (with a not very good internet connection) and the backend in AWS Lambda was not bad.

    If you allow me, I would like to ask another question: do you think some of the functionalities of ASP.NET Zero will not work in a serverless environment? I was thinking about components like Hangfire, which would need the application to be always available. Do you think this kind of environment would impose somme kind of limitation?

    Regards.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @adm.zepp,

    I'm glad that it worked for you at least in a way. You are right, probably you shouldn't use Hangfire. Other than hat, default functionality of AspNet Zero should work fine (Hangfire is not enabled by defualt).

  • User Avatar
    0
    adm.zepp created

    Hi @ismcagdas

    I see, maybe we should not use Hangfire in AWS Lambda. I think there are ways of making the lambda function always available, but that would probably harm one of the most attractive reasons to use AWS Lambda in the first place, which is being billed just when the function is actually running.

    The only feature of ASP.NET Zero that we had to turn off was logging, but that was just to be able to continue with the testes. We could chenge log4net configuration to use the database instead of files. And there is a AWS Lambda package that is a logging provider compatible with the ILogger interface and that directs logs to AWS CloudWatch. It might even work with Castle.

    Well, thank you very much for all the support.

    Best regards.

  • User Avatar
    0
    alper created
    Support Team

    hi,

    According to the API Gateway Limits; it's clearly stated that the timeout limit is 29 seconds and cannot be changed. See the AWS limits: <a class="postlink" href="https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html">https://docs.aws.amazon.com/apigateway/ ... imits.html</a> . See the related issue: <a class="postlink" href="https://github.com/serverless/serverless/issues/3171">https://github.com/serverless/serverless/issues/3171</a>

  • User Avatar
    0
    adm.zepp created

    Hi @alper

    I guess you're right. Thank you for the information. It turned out we had made a mistake in serverless.template file (more precisely in the event that triggers the function).

    Thank you again.

  • User Avatar
    0
    alper created
    Support Team

    no problem. Hope you'll get it working soon ;)