Giter VIP home page Giter VIP logo

functionmonkey's Introduction

Function Monkey

Write more elegant Azure Functions with less boilerplate, more consistency, and support for REST APIs.

public class FunctionAppConfiguration : IFunctionAppConfiguration
{
    public void Build(IFunctionHostBuilder builder)
    {
        builder
            .Setup((serviceCollection, commandRegistry) =>
            {
                serviceCollection
                    .AddLogging()
                    .AddNotificationServices(commandRegistry)
                    .AddExpensesService(commandRegistry)
                    .AddInvoiceServices(commandRegistry);
            })
            .Authorization(authorization => authorization.TokenValidator())
            .AddFluentValidation()
            .Functions(functions => functions
                .HttpRoute("v1/Invoice", route => route
                    .HttpFunction(AuthorizationTypeEnum.TokenValidation, HttpMethod.Get)
                )
                .ServiceBus("serviceBusConnection", serviceBus => serviceBus
                    .SubscriptionFunction("emaildispatchtopic", "emaildispatchsubscription"))
                .Storage("storageConnectionString", storage => storage
                    .BlobFunction("expenses/{name}"))
            );
    }
}

Getting Started

Full documentation is available here:

https://functionmonkey.azurefromthetrenches.com

In addition there is a video tutorial series on building out a simple application:

Video tutorial series

https://www.youtube.com/playlist?list=PLB09mElO-eDipUqGup9d8GFCL2KUj1JYx

functionmonkey's People

Contributors

akomyshan avatar alexeymarkov avatar awarrenlove avatar cheranga avatar davidesan avatar jamesrandall avatar markusbernhardt avatar mrbliz avatar vip32 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

functionmonkey's Issues

NullReferenceException when Content-type unspecified.

For reproduce this error you simply can run Getting started example.

In current version we must set Content-type for all requests, but in case of GET methods when we produce request from browser Content-type are not added to headers request.

I have research the HTTP Protocol specification and googling should we set Content-type for all requests and TL;DR: Get requests should not have content-type because they do not have request entity (that is, a body)

I suggest to make the Content-type is not required. (At least for GET requests)

Repro steps:

  1. Run https://functionmonkey.azurefromthetrenches.com/guides/gettingStarted.html this guide.
  2. Run HelloWorld function from browser.

Error example:

` Http Functions:

    HelloWorldProxy: [GET] http://localhost:7071/api/v1/HelloWorld

    HelloWorld: [GET] http://localhost:7071/api/HelloWorld

[01.02.2019 11:01:10] Executing HTTP request: {
[01.02.2019 11:01:10]   "requestId": "db8c0b57-3857-4c51-b99b-778140cf5f63",
[01.02.2019 11:01:10]   "method": "GET",
[01.02.2019 11:01:10]   "uri": "/api/v1/HelloWorld"
[01.02.2019 11:01:10] }
[01.02.2019 11:01:11] Executing 'Functions.HelloWorldProxy' (Reason='This function was programmatically called via the host APIs.', Id=796ca58c-035e-41ee-ad26-ae9464a70c2c)
[01.02.2019 11:01:11] Host lock lease acquired by instance ID '00000000000000000000000011CD3113'.
[01.02.2019 11:01:11] Executing request via Azure Function Proxies
[01.02.2019 11:01:11] Executing 'HelloWorld' (Reason='This function was programmatically called via the host APIs.', Id=7e582cfa-c725-4dc0-933b-4b742d30ac1b)
[01.02.2019 11:01:12] HTTP trigger function HelloWorld processed a request.
[01.02.2019 11:01:16] Executed 'HelloWorld' (Failed, Id=7e582cfa-c725-4dc0-933b-4b742d30ac1b)

[01.02.2019 11:01:16] System.Private.CoreLib: Exception while executing function: HelloWorld. TestNRE.Functions.dll: Object reference not set to an instance of an object.

[01.02.2019 11:01:16] Executed 'Functions.HelloWorldProxy' (Succeeded, Id=796ca58c-035e-41ee-ad26-ae9464a70c2c)
[01.02.2019 11:01:17] Executed HTTP request: {
[01.02.2019 11:01:17]   "requestId": "db8c0b57-3857-4c51-b99b-778140cf5f63",
[01.02.2019 11:01:17]   "method": "GET",
[01.02.2019 11:01:17]   "uri": "/api/v1/HelloWorld",
[01.02.2019 11:01:17]   "identities": [
[01.02.2019 11:01:17]     {
[01.02.2019 11:01:17]       "type": "WebJobsAuthLevel",
[01.02.2019 11:01:17]       "level": "Admin"
[01.02.2019 11:01:17]     }
[01.02.2019 11:01:17]   ],
[01.02.2019 11:01:17]   "status": 500,
[01.02.2019 11:01:17]   "duration": 6194
[01.02.2019 11:01:17] }`

Error reason:

Looks like trouble in http.csharp.handlebars file in line
string contentType = req.ContentType.ToLower();

UPD: I can suggest a PR to fix this bug, but I don't have permissions to push.

Optional Route Parameters

Nice project, will write blog post on it when time allows.

I know that the docs say route parameters are not optional, but is this going to be a permanent limitation?

Compile error

Hey James, I followed your blog post to setup a simple REST API, but getting this error when compiling:

MSB3073 The command "dotnet "C:\Users\engj.nuget\packages\compilecommandingfunctions\0.2.0-beta000\build\netstandard1.0....\tools\netcoreapp2.0/CompileCommandingFunctions.dll" C:\Users\engj\source\repos\Experimental\FunctionApp1\bin\Debug\netstandard2.0\bin\FunctionApp1.dll C:\Users\engj\source\repos\Experimental\FunctionApp1\bin\Debug\netstandard2.0" exited with code -532462766.FunctionApp1C:\Users\engj.nuget\packages\compilecommandingfunctions\0.2.0-beta000\build\netstandard1.0\CompileCommandingFunctions.targets9

Any ideas?

image

FunctionMonkey.Compiler errors when assembly refers to BigInteger

Self-contained reproducible solution at this commit: tonesandtones/KnockKnock@fa26206

Built with dotnet core SDK 2.1.402
Az function project targetting netcoreapp2.0
FunctionMonkey 0.13.0-beta000
FunctionMonkey.Compiler 0.13.2-beta000

2>Unhandled Exception: FunctionMonkey.ConfigurationException: CS0433:The type 'StreamReader' exists in both 'System.Runtime.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' SourceFile([1367..1379))CS0433:The type 'StreamReader' exists in both 'System.Runtime.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' SourceFile([1393..1405))CS0433:The type 'StreamReader' exists in both 'System.Runtime.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' SourceFile([1147..1159))
2>   at FunctionMonkey.Compiler.Implementation.AssemblyCompiler.CompileAssembly(IReadOnlyCollection`1 syntaxTrees, IReadOnlyCollection`1 externalAssemblies, OpenApiOutputModel openApiOutputModel, String outputBinaryFolder, String outputAssemblyName, String assemblyNamespace)
2>   at FunctionMonkey.Compiler.Implementation.FunctionCompiler.Compile() in D:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey.Compiler\Implementation\FunctionCompiler.cs:line 86
2>   at FunctionMonkey.Compiler.Program.Main(String[] args) in D:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey.Compiler\Program.cs:line 45
2>C:\Users\******\.nuget\packages\functionmonkey.compiler\0.13.2-beta000\build\netstandard1.0\FunctionMonkey.Compiler.targets(11,5): error MSB3073: The command "dotnet "C:\Users\anthony\.nuget\packages\functionmonkey.compiler\0.13.2-beta000\build\netstandard1.0\..\..\tools\netcoreapp2.0/FunctionMonkey.Compiler.dll" "C:\projects\readify\KnockKnock2\KnockKnock.Api.Function\bin\Debug\netstandard2.0\bin\KnockKnock.Api.Function.dll"" exited with code -532462766.
2>Done building project "KnockKnock.Api.Function.csproj" -- FAILED.

AbstractFunctionDefinition.CommandResultType Single explodes if I inherit an interface from ICommand<T>

For example, the following code throws an exception at build in FM.Compiler.

public interface ICustomCommand<T>: ICommand<T> { } // some custom stuff
public class MyFooCustomCommand: ICustomCommand<Foo>

The code throwing the exception is:

Type genericCommandInterface = CommandType.GetInterfaces()
.SingleOrDefault(x => x.IsGenericType && commandInterface.IsAssignableFrom(x));

Because the GetInterfaces() is returning ICommand<Foo> and ICustomCommand<Foo>.

It seems you are looking for just ICommand<Foo> in this case. Since this is at compile, you could narrow it down by adding a check on the interfaces for x. ICommand<Foo> will only have the one so && x.GetInterfaces().Count() ==1 would work (since you are already checking IsAssignableFrom(x)).

Thoughts?

Unable to access db connection string

Hello

I am trying to get the connection string through IOptions.

builder
.Setup((serviceCollection, commandRegistry) =>
{
serviceCollection.AddLogging();

                //serviceCollection.AddOptions();

                serviceCollection.AddOptions<DbSettings>("DbSettings");

....
....

DbSettings is defined in local.settings.json.

However, when I access this through the constructor of the command handler, the value is coming as null.

Any help is appreciated.

Thanks
Kris

Setting Status Code from A HTTP Trigger

How do you control the return status code from a HTTP trigger, eg: when a resource is not found and you want to return a 404? There doesn't seem to be anything on the Contextprovider to use here. And from looking at the templates in the source code, returning a HTTPResponseMessage from your handlers seems to be a no no?

public class GetEventByIdHandler : ICommandHandler<EventQuery, EventModel>
    {
        private readonly DBContext _context;
        private readonly IContextProvider _provider;

        public GetEventByIdHandler(DBContext context, IContextProvider provider)
        {
            _context = context;
            _provider = provider;
        }

        public async Task<EventModel> ExecuteAsync(EventQuery query, EventModel previousResult)
        {
            var @event = await _context.Events
                .Where(x => x.EventId == query.Id)
                .BuildEventModel()
                .FirstOrDefaultAsync();

           //If Event is null return 404

           return @event
        }
    }

Compiler error

1>------ Build started: Project: EML, Configuration: Debug Any CPU ------
1>C:\Users\melgs.nuget\packages\microsoft.net.sdk.functions\1.0.24\build\netstandard1.0\Microsoft.NET.Sdk.Functions.props(38,3): warning MSB4011: "C:\Users\melgs.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.0.1\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.props" cannot be imported again. It was already imported at "C:\GIT\myAzureFunction\EML\EML\obj\EML.csproj.nuget.g.props (17,5)". This is most likely a build authoring error. This subsequent import will be ignored. [C:\GIT\myAzureFunction\EML\EML\EML.csproj]
1>C:\Users\melgs.nuget\packages\microsoft.net.sdk.functions\1.0.24\build\netstandard1.0\Microsoft.NET.Sdk.Functions.targets(45,3): warning MSB4011: "C:\Users\melgs.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.0.1\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets" cannot be imported again. It was already imported at "C:\GIT\myAzureFunction\EML\EML\obj\EML.csproj.nuget.g.targets (9,5)". This is most likely a build authoring error. This subsequent import will be ignored. [C:\GIT\myAzureFunction\EML\EML\EML.csproj]
1>C:\GIT\myAzureFunction\EML\EML\EML.csproj : warning NU1701: Package 'Microsoft.Azure.WebJobs.Extensions.DocumentDB 1.1.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project.
1>EML -> C:\GIT\myAzureFunction\EML\EML\bin\Debug\netcoreapp2.1\bin\EML.dll
1>
1>Unhandled Exception: FunctionMonkey.TypeLoadingException: ReflectionTypeLoadException: Unable to load one or more of the requested types.
1>Could not load file or assembly 'Microsoft.Azure.DocumentDB.Core, Version=2.1.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621)
1>Unable to load types:
1> AccountManagement.ServiceTestRequest
1> AccountManagement.FileAccess
1> AccountManagement.FileIOPermissionAccess
1> AccountManagement.ServiceTestResponse
1> AccountManagement.AutoMapperTestResult
1> AccountManagement.DtoTestResult
1> AccountManagement.FailedTestTypes
1> AccountManagement.FilePermissionTestResult
1> AccountManagement.ServiceTestResult
1> AccountManagement.ServicePingResult
1> AccountManagement.TestResultBase
1> AccountManagement.ExternalRequest
1> AccountManagement.SecurityRequest
1> AccountManagement.GetAccountDetailsRequest
1> AccountManagement.ActivatePlasticCardRequest
1> AccountManagement.DeactivatePlasticCardRequest
1> AccountManagement.DeactivateCardRequest
1> AccountManagement.GetAccountStatusRequest
1> AccountManagement.GetAccountDipRequest
1> AccountManagement.UpdateAccountDetailsRequest
1> AccountManagement.CreateAccountRequest
1> AccountManagement.GetMobileWalletDataRequest
1> AccountManagement.GetApplePayWalletDataRequest
1> AccountManagement.GetMobileWalletTokensRequest
1> AccountManagement.GetAccountFreeFieldDefinitionsRequest
1> AccountManagement.UpdateAccountFreeFieldsRequest
1> AccountManagement.GetAccountFreeFieldsRequest
1> AccountManagement.ActivateCardRequest
1> AccountManagement.ExternalAccountIdentifier
1> AccountManagement.DetailFlags
1> AccountManagement.ClientDetails
1> AccountManagement.UserCredentials
1> AccountManagement.WalletProvider
1> AccountManagement.FreeFieldData
1> AccountManagement.FreeFieldName
1> AccountManagement.FreeFieldType
1> AccountManagement.BaseResponse
1> AccountManagement.ErrorCode
1> AccountManagement.GetAccountDetailsResponse
1> AccountManagement.ActivatePlasticCardResponse
1> AccountManagement.DeactivatePlasticCardResponse
1> AccountManagement.DeactivateCardResponse
1> AccountManagement.GetAccountStatusResponse
1> AccountManagement.GetAccountDipResponse
1> AccountManagement.UpdateAccountDetailsResponse
1> AccountManagement.CreateAccountResponse
1> AccountManagement.GetMobileWalletDataResponse
1> AccountManagement.GetApplePayWalletDataResponse
1> AccountManagement.GetMobileWalletTokensResponse
1> AccountManagement.GetAccountFreeFieldDefinitionsResponse
1> AccountManagement.UpdateAccountFreeFieldsResponse
1> AccountManagement.GetAccountFreeFieldsResponse
1> AccountManagement.ActivateCardResponse
1> AccountManagement.AccountDetails
1> AccountManagement.CardState
1> AccountManagement.ProductType
1> AccountManagement.Provider
1> AccountManagement.Token
1> AccountManagement.Device
1> AccountManagement.TokenStatus
1> AccountManagement.TokenisationDecision
1> AccountManagement.ProvisioningStatus
1> AccountManagement.StorageTechnology
1> AccountManagement.Suspender
1> AccountManagement.TokenType
1> AccountManagement.DeviceType
1> AccountManagement.FreeFieldDefinition
1> AccountManagement.IAccountManagementService
1> AccountManagement.IAccountManagementServiceChannel
1> AccountManagement.AccountManagementServiceClient
1> EML.AuthDelegatingHandler
1> EML.Extension
1> EML.Members
1> EML.Authenticated
1> EML.FunctionAppConfiguration
1> EML.Models.AuthToken
1> EML.Models.Account
1> EML.Models.AccountStatus
1> EML.Models.ProgramDTO
1> EML.Models.ClientDTO
1> EML.Models.CompanyDTO
1> EML.Models.UserPermissions
1> EML.Models.ProgramPermission
1> EML.Models.UserType
1> EML.Models.EMLRole
1> EML.Models.ClientRole
1> EML.Models.ProgramRole
1> EML.Models.ProgramTypes
1> EML.Models.ClientUser
1> EML.Models.EMLUser
1> EML.Models.EML
1> EML.Models.Client
1> EML.Models.Program
1> EML.Models.Company
1> EML.Models.Card
1> EML.Models.CardHolder
1> EML.Handlers.BatchesCommandHandler
1> EML.Handlers.HelloWorldCommandHandler
1> EML.Handlers.PermissionsCommandHandler
1> EML.Handlers.ProgramsCommandHandler
1> EML.Handlers.UserPermissionsCommandHandler
1> EML.Commands.BatchesCommand
1> EML.Commands.HelloWorldCommand
1> EML.Commands.ICommand`2
1> EML.Commands.PermissionsCommand
1> EML.Commands.ProgramsCommand
1> EML.Commands.UserPermissionsCommand
1> AccountManagement.AccountManagementServiceClient+EndpointConfiguration
1> EML.AuthDelegatingHandler+d__0
1> EML.Authenticated+d__5
1> EML.Authenticated+<>o__6
1> EML.Authenticated+<>c
1> EML.FunctionAppConfiguration+<>c
1> EML.Handlers.BatchesCommandHandler+d__0
1> EML.Handlers.PermissionsCommandHandler+d__0
1> null type in ReflectionTypeLoadException
1>With errors:
1> FileLoadException: Could not load file or assembly 'Microsoft.Azure.DocumentDB.Core, Version=2.1.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621)
1>
1> at FunctionMonkey.ConfigurationLocator.FindConfiguration(Assembly assembly) in /Users/jamesrandall/code/myOpenSource/functionMonkey/Source/FunctionMonkey/ConfigurationLocator.cs:line 115
1> at FunctionMonkey.Compiler.Implementation.FunctionCompiler.Compile() in /Users/jamesrandall/code/myOpenSource/functionMonkey/Source/FunctionMonkey.Compiler/Implementation/FunctionCompiler.cs:line 64
1> at FunctionMonkey.Compiler.Program.Main(String[] args) in /Users/jamesrandall/code/myOpenSource/functionMonkey/Source/FunctionMonkey.Compiler/Program.cs:line 47
1>C:\Users\melgs.nuget\packages\functionmonkey.compiler\0.18.7-beta000\build\netstandard1.0\FunctionMonkey.Compiler.targets(21,5): error MSB3073: The command "dotnet "C:\Users\melgs.nuget\packages\functionmonkey.compiler\0.18.7-beta000\build\netstandard1.0....\tools\netcoreapp2.1/FunctionMonkey.Compiler.dll" "C:\GIT\myAzureFunction\EML\EML\bin\Debug\netcoreapp2.1\bin\EML.dll" --netcore21" exited with code -532462766.
1>Done building project "EML.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

build error if the project name has dash in it

using vscode I have created a function app with name "azdeployer-api". following your example I have created FunctionAppConfiguration.cs, a command DeployTemplateCommand.cs and a command handler DeployTemplateCommandHandler.cs. It fails with below error

Unhandled Exception: FunctionMonkey.ConfigurationException: CS0116:A namespace cannot directly contain members such as fields or methods SourceFile([443..452))CS0116:A namespace cannot directly contain members such as fields or methods SourceFile([381..390))CS0116:A namespace cannot directly contain members such as fields or methods SourceFile([266..275))CS1514:{ expected SourceFile([438..439))CS1022:Type or namespace definition, or end-of-file expected SourceFile([454..455))CS1514:{ expected SourceFile([261..262))CS1022:Type or namespace definition, or end-of-file expected SourceFile([277..278))CS1514:{ expected SourceFile([376..377))CS1022:Type or namespace definition, or end-of-file expected SourceFile([392..393))
     at FunctionMonkey.Compiler.Implementation.AssemblyCompiler.CompileAssembly(IReadOnlyCollection`1 syntaxTrees, IReadOnlyCollection`1 externalAssemblyLocations, OpenApiOutputModel openApiOutputModel, String outputBinaryFolder, String outputAssemblyName, String assemblyNamespace, TargetEnum target)
     at FunctionMonkey.Compiler.Implementation.FunctionCompiler.Compile() in D:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey.Compiler\Implementation\FunctionCompiler.cs:line 86
     at FunctionMonkey.Compiler.Program.Main(String[] args) in D:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey.Compiler\Program.cs:line 47
  /var/folders/dq/_qnynrwx3470y8wzy4w63ll1px_yqt/T/tmpec9acaa42b4e4065a95663ef81367e2a.exec.cmd: line 2: 19711 Abort trap: 6           dotnet "/Users/rjanjya/.nuget/packages/functionmonkey.compiler/1.1.2/build/netstandard1.0/../../tools/netcoreapp2.1/FunctionMonkey.Compiler.dll" "/Users/rjanjya/repos/azdeployer-api/bin/Debug/netcoreapp2.1/bin/azdeployer-api.dll" --netcore21
/Users/rjanjya/.nuget/packages/functionmonkey.compiler/1.1.2/build/netstandard1.0/FunctionMonkey.Compiler.targets(21,5): error MSB3073: The command "dotnet "/Users/rjanjya/.nuget/packages/functionmonkey.compiler/1.1.2/build/netstandard1.0/../../tools/netcoreapp2.1/FunctionMonkey.Compiler.dll" "/Users/rjanjya/repos/azdeployer-api/bin/Debug/netcoreapp2.1/bin/azdeployer-api.dll" --netcore21" exited with code 134. [/Users/rjanjya/repos/azdeployer-api/azdeployer-api.csproj]

Build FAILED.

/Users/rjanjya/.nuget/packages/functionmonkey.compiler/1.1.2/build/netstandard1.0/FunctionMonkey.Compiler.targets(21,5): error MSB3073: The command "dotnet "/Users/rjanjya/.nuget/packages/functionmonkey.compiler/1.1.2/build/netstandard1.0/../../tools/netcoreapp2.1/FunctionMonkey.Compiler.dll" "/Users/rjanjya/repos/azdeployer-api/bin/Debug/netcoreapp2.1/bin/azdeployer-api.dll" --netcore21" exited with code 134. [/Users/rjanjya/repos/azdeployer-api/azdeployer-api.csproj]
    0 Warning(s)
    1 Error(s)

I also have that helloworld example from your blog which is working fine but not this one. Error message is also not helpful because I have namespaces, classes and methods created correctly.

skeptical about the name I have now created a new project without dash in its name . azdeployerapi. it has the same configuration, command and command handler files inside it. This one builds succesfully without any issue. so I guess having dash (-) in its name is causing a project not to build. Please look into it.

Compiler error

I have been attempting to work with entity frameworks cosmos provider and function monkey.

1>------ Build started: Project: Tutorial, Configuration: Debug Any CPU ------
1>Tutorial -> C:\GIT\myAzureFunction\FunctionMonkey\Tutorial\bin\Debug\netcoreapp2.1\bin\Tutorial.dll
1>
1>Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621)
1> at Tutorial.ServerlessBlogConfiguration.Build(IFunctionHostBuilder builder)
1> at FunctionMonkey.Compiler.Implementation.FunctionCompiler.Compile() in C:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey.Compiler\Implementation\FunctionCompiler.cs:line 73
1> at FunctionMonkey.Compiler.Program.Main(String[] args) in C:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey.Compiler\Program.cs:line 47
1>C:\Users\melgs.nuget\packages\functionmonkey.compiler\0.18.6-beta000\build\netstandard1.0\FunctionMonkey.Compiler.targets(19,5): error MSB3073: The command "dotnet "C:\Users\melgs.nuget\packages\functionmonkey.compiler\0.18.6-beta000\build\netstandard1.0....\tools\netcoreapp2.1/FunctionMonkey.Compiler.dll" "C:\GIT\myAzureFunction\FunctionMonkey\Tutorial\bin\Debug\netcoreapp2.1\bin\Tutorial.dll" --netcore21" exited with code -532462766.
1>Done building project "Tutorial.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

Unable to code according to example for Storage Blob

Hi

First of all, thanks for the effort putting up something useful.

When following the examples provided here, the sample code provided for the following code snippet will not compile. The variable 'name' does not correspond to a corresponding variable, hence the error.

How can I rectify this?

image

Reflection type exception when compiling function project

Hi there,

I've been testing Function Monkey on a new project and I think it's great. However, I've run into an issue a couple of times now when trying to incorporate some Cosmos DB stuff. I managed to resolve it the last time by changing package versions, but thought I'd post it this time as I'm struggling to get past it this time. Not sure if you can help.

Error -

The command "dotnet "C:\Users\Administrator.nuget\packages\functionmonkey.compiler\0.10.2-beta000\build\netstandard1.0....\tools\netcoreapp2.0/FunctionMonkey.Compiler.dll" "D:\GitHub\letsbuildit\src\LetsBuildIt.Web.API.FM\bin\Debug\netstandard2.0\bin\LetsBuildIt.Web.API.FM.dll"" exited with code -532462766. LetsBuildIt.Web.API.FM C:\Users\Administrator.nuget\packages\functionmonkey.compiler\0.10.2-beta000\build\netstandard1.0\FunctionMonkey.Compiler.targets 10

Output:

1>Unhandled Exception: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
1> at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
1> at System.Reflection.Assembly.GetTypes()
1> at FunctionMonkey.ConfigurationLocator.FindConfiguration(Assembly assembly) in D:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey\ConfigurationLocator.cs:line 78
1> at FunctionMonkey.Compiler.Implementation.FunctionCompiler.Compile() in D:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey.Compiler\Implementation\FunctionCompiler.cs:line 56
1> at FunctionMonkey.Compiler.Program.Main(String[] args) in D:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey.Compiler\Program.cs:line 45
1>C:\Users\Administrator.nuget\packages\functionmonkey.compiler\0.10.2-beta000\build\netstandard1.0\FunctionMonkey.Compiler.targets(10,5): error MSB3073: The command "dotnet "C:\Users\Administrator.nuget\packages\functionmonkey.compiler\0.10.2-beta000\build\netstandard1.0....\tools\netcoreapp2.0/FunctionMonkey.Compiler.dll" "D:\GitHub\letsbuildit\src\LetsBuildIt.Web.API.FM\bin\Debug\netstandard2.0\bin\LetsBuildIt.Web.API.FM.dll"" exited with code -532462766.

Build error

Hi, here comes in my first build, anythings I missed in the configuration? Thanks!

`Unhandled Exception: FunctionMonkey.TypeLoadingException: ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Unable to load types:
null type in ReflectionTypeLoadException
null type in ReflectionTypeLoadException
null type in ReflectionTypeLoadException
null type in ReflectionTypeLoadException
With errors:
FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

at FunctionMonkey.ConfigurationLocator.FindConfiguration(Assembly assembly) in C:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey\ConfigurationLocator.cs:line 115
at FunctionMonkey.Compiler.Implementation.FunctionCompiler.Compile() in C:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey.Compiler\Implementation\FunctionCompiler.cs:line 55
at FunctionMonkey.Compiler.Program.Main(String[] args) in C:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey.Compiler\Program.cs:line 45
`

Allow JSON Response to have custom settings

Hello
Thank you for this library, it is really useful and really appreciate this.

I would like to know whether the framework allows to have my own CreateResponse method.
Mainly, we are using SnakeCaseNamingStrategy instead of CamelCasePropertyNamesContractResolver for the JSON.

public static IActionResult CreateResponse(int code, object content)
{
ContentResult result = new ContentResult();
result.Content = JsonConvert.SerializeObject(content, Formatting.Indented,
new JsonSerializerSettings {ContractResolver = new CamelCasePropertyNamesContractResolver()});
<-- can this be SnakeCaseNamingStrategy()
result.ContentType = "application/json";
result.StatusCode = code;
return result;
}

Our ASP.NET Core MVC is using:

services.AddMvc(config => {
config.Filters.Add(typeof(CustomExceptionFilter));
}).AddJsonOptions(opts =>
{
opts.SerializerSettings.ContractResolver = new DefaultContractResolver
{
NamingStrategy = new SnakeCaseNamingStrategy()
};
opts.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
}); ;

Thanks
Kris

Publish fails with FunctionMonkey.ConfigurationException: CS1705

After I updated to 0.18.6 which fixed all my other problems, my VSTS build started failing. Im using the standard function app deployment template which does a build and publish.
I noticed that it passed running the 'after build' compile, but failed the 'after publish' compile with the error:
FunctionMonkey.ConfigurationException: CS1705:Assembly 'FunctionApp3' with identity 'FunctionApp3, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Runtime' with identity 'System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' SourceFile([3106..3147))
I get the same error running the dontnet command from the command line.

After some digging I saw that in FunctionMonkey.Compiler.targets, you are differentiating the FunctionCompilerParams for dotnetcore and adding --netcore21. That is not being done for FunctionPublishParams.

Adding that flag to the command line seems to fix the error, but I don't have a way to do that from my VSTS build.

Error when upgrading to 0.18

Sorry James,

Get this when i upgrade to latest 0.18, rolling back to 0.17 works.

Let me know if you need anything else to help debug

1>Unhandled Exception: FunctionMonkey.ConfigurationException: CS7036:There is no argument given that corresponds to the required formal parameter 'serializer' of 'HelloWorld.CreateResponse(int, object, ISerializer)' SourceFile([3492..3506))
1>   at FunctionMonkey.Compiler.Implementation.AssemblyCompiler.CompileAssembly(IReadOnlyCollection`1 syntaxTrees, IReadOnlyCollection`1 externalAssemblyLocations, OpenApiOutputModel openApiOutputModel, String outputBinaryFolder, String outputAssemblyName, String assemblyNamespace, TargetEnum target)
1>   at FunctionMonkey.Compiler.Implementation.FunctionCompiler.Compile() in /Users/jamesrandall/code/myOpenSource/functionMonkey/Source/FunctionMonkey.Compiler/Implementation/FunctionCompiler.cs:line 94
1>   at FunctionMonkey.Compiler.Program.Main(String[] args) in /Users/jamesrandall/code/myOpenSource/functionMonkey/Source/FunctionMonkey.Compiler/Program.cs:line 47
1>C:\Users\xxx\.nuget\packages\functionmonkey.compiler\0.18.2-beta000\build\netstandard1.0\FunctionMonkey.Compiler.targets(19,5): error MSB3073: The command "dotnet "C:\Users\xxx\.nuget\packages\functionmonkey.compiler\0.18.2-beta000\build\netstandard1.0\..\..\tools\netcoreapp2.1/FunctionMonkey.Compiler.dll" "C:\_Git\NXG\OnBoarding.Functions\OnBoarding.Functions\bin\Debug\netstandard2.0\bin\OnBoarding.Functions.dll"" exited with code -532462766.

Error with compiling code

When attempting to compile I was first greeted with the following:

Microsoft (R) Build Engine version 15.7.179.6572 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 74.92 ms for /Users/adamshort/Desktop/Code/collaboro/ice/ICE/ICE.csproj.
  ICE -> /Users/adamshort/Desktop/Code/collaboro/ice/ICE/bin/Debug/netstandard2.0/bin/ICE.dll
  No executable found matching command "dotnet-/Users/adamshort/.nuget/packages/functionmonkey.compiler/0.11.0-beta000/build/netstandard1.0/..\..\tools\netcoreapp2.0\FunctionMonkey.Compiler.dll"
/Users/adamshort/.nuget/packages/functionmonkey.compiler/0.11.0-beta000/build/netstandard1.0/FunctionMonkey.Compiler.targets(10,5): error MSB3073: The command "dotnet "/Users/adamshort/.nuget/packages/functionmonkey.compiler/0.11.0-beta000/build/netstandard1.0/..\..\tools\netcoreapp2.0\FunctionMonkey.Compiler.dll" "/Users/adamshort/Desktop/Code/collaboro/ice/ICE/bin/Debug/netstandard2.0/bin/ICE.dll"" exited with code 1. [/Users/adamshort/Desktop/Code/collaboro/ice/ICE/ICE.csproj]

Build FAILED.

/Users/adamshort/.nuget/packages/functionmonkey.compiler/0.11.0-beta000/build/netstandard1.0/FunctionMonkey.Compiler.targets(10,5): error MSB3073: The command "dotnet "/Users/adamshort/.nuget/packages/functionmonkey.compiler/0.11.0-beta000/build/netstandard1.0/..\..\tools\netcoreapp2.0\FunctionMonkey.Compiler.dll" "/Users/adamshort/Desktop/Code/collaboro/ice/ICE/bin/Debug/netstandard2.0/bin/ICE.dll"" exited with code 1. [/Users/adamshort/Desktop/Code/collaboro/ice/ICE/ICE.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:03.83

After a bit of digging around, I found that inside of netstandard1.0/FunctionMonkey.Compiler.targets I was specifying this path with:

    <FunctionCompilerExe Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' OR '$(TargetFrameworkIdentifier)' == '.NETStandard'">dotnet "$(MSBuildThisFileDirectory)..\..\tools\netcoreapp2.0\FunctionMonkey.Compiler.dll"</FunctionCompilerExe>

Surprisingly, the direction of those slashes was actually important - when I reversed them, I located the DLL correctly (I verified in the terminal that it was in fact at that location too)

    <FunctionCompilerExe Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' OR '$(TargetFrameworkIdentifier)' == '.NETStandard'">dotnet "$(MSBuildThisFileDirectory)../../tools/netcoreapp2.0/FunctionMonkey.Compiler.dll"</FunctionCompilerExe>

However, this might of fixed that issue but it uncovered a much more troublesome issue that I can't fix.

Microsoft (R) Build Engine version 15.7.179.6572 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 66.52 ms for /Users/adamshort/Desktop/Code/collaboro/ice/ICE/ICE.csproj.
  ICE -> /Users/adamshort/Desktop/Code/collaboro/ice/ICE/bin/Debug/netstandard2.0/bin/ICE.dll
  
  Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
     at FunctionMonkey.ConfigurationLocator.FindConfiguration(Assembly assembly) in D:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey\ConfigurationLocator.cs:line 95
     at FunctionMonkey.Compiler.Implementation.FunctionCompiler.Compile() in D:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey.Compiler\Implementation\FunctionCompiler.cs:line 56
     at FunctionMonkey.Compiler.Program.Main(String[] args) in D:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey.Compiler\Program.cs:line 44
  /var/folders/ws/8qmgsd2d5qzgk18kqcr5tgb80000gn/T/tmp76d75810b305435184c34e47eb5e1137.exec.cmd: line 2: 39374 Abort trap: 6           dotnet "/Users/adamshort/.nuget/packages/functionmonkey.compiler/0.11.0-beta000/build/netstandard1.0/../../tools/netcoreapp2.0/FunctionMonkey.Compiler.dll" "/Users/adamshort/Desktop/Code/collaboro/ice/ICE/bin/Debug/netstandard2.0/bin/ICE.dll"
/Users/adamshort/.nuget/packages/functionmonkey.compiler/0.11.0-beta000/build/netstandard1.0/FunctionMonkey.Compiler.targets(10,5): error MSB3073: The command "dotnet "/Users/adamshort/.nuget/packages/functionmonkey.compiler/0.11.0-beta000/build/netstandard1.0/../../tools/netcoreapp2.0/FunctionMonkey.Compiler.dll" "/Users/adamshort/Desktop/Code/collaboro/ice/ICE/bin/Debug/netstandard2.0/bin/ICE.dll"" exited with code 134. [/Users/adamshort/Desktop/Code/collaboro/ice/ICE/ICE.csproj]

Build FAILED.

/Users/adamshort/.nuget/packages/functionmonkey.compiler/0.11.0-beta000/build/netstandard1.0/FunctionMonkey.Compiler.targets(10,5): error MSB3073: The command "dotnet "/Users/adamshort/.nuget/packages/functionmonkey.compiler/0.11.0-beta000/build/netstandard1.0/../../tools/netcoreapp2.0/FunctionMonkey.Compiler.dll" "/Users/adamshort/Desktop/Code/collaboro/ice/ICE/bin/Debug/netstandard2.0/bin/ICE.dll"" exited with code 134. [/Users/adamshort/Desktop/Code/collaboro/ice/ICE/ICE.csproj]
    0 Warning(s)
    1 Error(s)

If you need any details I will happily provide. I am building a production system using this platform as I actually was going to build all of this myself before I stumbled upon the framework thanks to a tip from a mate (how lucky!!!).

Happy to help however I can! The only potential thing I can think of is that my DLL resides within netstandard2.0, while FM.Compiler seems to be in netstandard1.0?

No job functions found. Try making your job classes and methods public.

No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).

Azure Functions Core Tools (2.3.199 Commit hash: fdf734b09806be822e7d946fe17928b419d8a289)
Function Runtime Version: 2.0.12246.0

Forked the repo and added as existing projects then created reference built and played.

This is because I wan to update the microsoft azure document db core library and potentially the microsoft extensions dependency injection library.

Looks like I only have function monkey compiler 0.18.6-beta000 but my nuget package is 0.18.7-beta000. Not sure how to update my codes.

Header Mapping doesn't work as expected.

Header Mapping doesn't work as expected.
I want to bind my Authorization header to command property, in order to do this I use the following construction.
.HttpRoute("/Invoice", route => route
.HttpFunction(HttpMethod.Get)
.Options(options => options.AddHeaderMapping(x => x.Authorization, "Authorization"))
)

And this Authorization property always null.

Do you have any suggestions on why it can not work?

Enum property doesn't bind from query parameter.

I've created a simple program to demonstrate it.
There is the following enum.

public enum SortOrder
{
Ascending = 1,
Descending = 2
}

and command:

public class EnumCommand : ICommand<string>
{
public SortOrder Order { get; set; }
}

For all requests below, the Order field is alwayws 0.

http://localhost:7071/api/Enum?Order=Descending
http://localhost:7071/api/Enum?Order=Ascending
http://localhost:7071/api/Enum?Order=1
http://localhost:7071/api/Enum?Order=2

Do you have any suggestions why this doesn't work?

Blobs storage trigger throws exception during compilation

When attempting to build a Function App 2 project configured for blob trigger, it fail while building.

Using Visual Studio 2017 Version 15.8.2. Azure Functions and Web Jobs tools 15.10.2046.0.

Source code on Github here.

Error screenshot
image

1>------ Build started: Project: BlobFunctionAppTest, Configuration: Debug Any CPU ------
1>BlobFunctionAppTest -> D:\Playground\Azure > FunctionMonkey\FunctionMonkeyBlobTest\BlobFunctionAppTest\bin\Debug\netcoreapp2.0\bin\BlobFunctionAppTest.dll
1>
1>Unhandled Exception: FunctionMonkey.ConfigurationException: CS0246:The type or namespace name 'Uri' could not be found (are you missing a using directive or an assembly reference?) > SourceFile([518..521))CS0012:The type 'Uri' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.Uri, Version=4.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. SourceFile([1842..1870))
1> at FunctionMonkey.Compiler.Implementation.AssemblyCompiler.CompileAssembly(IReadOnlyCollection1 syntaxTrees, IReadOnlyCollection1 externalAssemblyLocations, OpenApiOutputModel openApiOutputModel, String outputBinaryFolder, String outputAssemblyName, String assemblyNamespace, TargetEnum target)
1> at FunctionMonkey.Compiler.Implementation.FunctionCompiler.Compile() in C:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey.Compiler\Implementation\FunctionCompiler.cs:line 94
1> at FunctionMonkey.Compiler.Program.Main(String[] args) in C:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey.Compiler\Program.cs:line 47

What might be the problem that is happening here?

Note: I used the output source in place of FunctionAppConfiguration, it worked as expected.

Could not load file or assembly "Newtonsoft.Json"

Hello again!
It appears the compiler is playing up again. At this point, I have finished coding the system and have gone to start my debugging & testing.

It was compiling and working fine right up until I reference Netwonsoft throughout some models to make sure the JSON Serialisation process succeeded correctly (well, it could have happened before then, but that was the latest change before I attempted to build it again).

Then, when I went to run unit tests, I get:

Microsoft (R) Build Engine version 15.7.179.6572 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 73.91 ms for /Users/adamshort/Desktop/Code/collaboro/ice/ICE/ICE.csproj.
Services/Implementations/TableService.cs(44,37): warning CS0168: The variable 'ex' is declared but never used [/Users/adamshort/Desktop/Code/collaboro/ice/ICE/ICE.csproj]
  ICE -> /Users/adamshort/Desktop/Code/collaboro/ice/ICE/bin/Debug/netstandard2.0/bin/ICE.dll
  
  Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.
  
     at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
     at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
     at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
     at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
     at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
     at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimePropertyInfo property, RuntimeType caType)
     at System.Attribute.InternalGetCustomAttributes(PropertyInfo element, Type type, Boolean inherit)
     at System.Attribute.GetCustomAttribute(MemberInfo element, Type attributeType, Boolean inherit)
     at System.Reflection.CustomAttributeExtensions.GetCustomAttribute[T](MemberInfo element)
     at FunctionMonkey.Infrastructure.PostBuildPatcher.<>c.<ExtractPossibleQueryParameters>b__3_0(PropertyInfo x) in D:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey\Infrastructure\PostBuildPatcher.cs:line 95
     at System.Linq.Enumerable.WhereSelectArrayIterator`2.ToArray()
     at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
     at FunctionMonkey.Infrastructure.PostBuildPatcher.ExtractPossibleQueryParameters(HttpFunctionDefinition httpFunctionDefinition1) in D:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey\Infrastructure\PostBuildPatcher.cs:line 92
     at FunctionMonkey.Infrastructure.PostBuildPatcher.Patch(FunctionHostBuilder builder, String newAssemblyNamespace) in D:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey\Infrastructure\PostBuildPatcher.cs:line 54
     at FunctionMonkey.Compiler.Implementation.FunctionCompiler.Compile() in D:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey.Compiler\Implementation\FunctionCompiler.cs:line 67
     at FunctionMonkey.Compiler.Program.Main(String[] args) in D:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey.Compiler\Program.cs:line 45
  /var/folders/ws/8qmgsd2d5qzgk18kqcr5tgb80000gn/T/tmpa999974e51404dffa5791cf067b9a5e3.exec.cmd: line 2: 91716 Abort trap: 6           dotnet "/Users/adamshort/.nuget/packages/functionmonkey.compiler/0.12.1-beta000/build/netstandard1.0/../../tools/netcoreapp2.0/FunctionMonkey.Compiler.dll" "/Users/adamshort/Desktop/Code/collaboro/ice/ICE/bin/Debug/netstandard2.0/bin/ICE.dll"
/Users/adamshort/.nuget/packages/functionmonkey.compiler/0.12.1-beta000/build/netstandard1.0/FunctionMonkey.Compiler.targets(11,5): error MSB3073: The command "dotnet "/Users/adamshort/.nuget/packages/functionmonkey.compiler/0.12.1-beta000/build/netstandard1.0/../../tools/netcoreapp2.0/FunctionMonkey.Compiler.dll" "/Users/adamshort/Desktop/Code/collaboro/ice/ICE/bin/Debug/netstandard2.0/bin/ICE.dll"" exited with code 134. [/Users/adamshort/Desktop/Code/collaboro/ice/ICE/ICE.csproj]

Build FAILED.

Services/Implementations/TableService.cs(44,37): warning CS0168: The variable 'ex' is declared but never used [/Users/adamshort/Desktop/Code/collaboro/ice/ICE/ICE.csproj]
/Users/adamshort/.nuget/packages/functionmonkey.compiler/0.12.1-beta000/build/netstandard1.0/FunctionMonkey.Compiler.targets(11,5): error MSB3073: The command "dotnet "/Users/adamshort/.nuget/packages/functionmonkey.compiler/0.12.1-beta000/build/netstandard1.0/../../tools/netcoreapp2.0/FunctionMonkey.Compiler.dll" "/Users/adamshort/Desktop/Code/collaboro/ice/ICE/bin/Debug/netstandard2.0/bin/ICE.dll"" exited with code 134. [/Users/adamshort/Desktop/Code/collaboro/ice/ICE/ICE.csproj]
    1 Warning(s)
    1 Error(s)

Time Elapsed 00:00:07.96

Which is a gleefully large error message that seems to be just saying that it can't find Newtonsoft.

Which is troubling, as I have 11.0.2 installed across the platform and it is referenced from multiple dependencies as well. I have tried clearing the bin & obj, restoring, reinstalling Newtonsoft, downgrading Newtonsoft, ect...

But with no success.

Let me know if there are any other details you require,
Cheers,
Adam.

dotnet quit unexpectedly

I get this when trying to use FunctionMonkey with the following assemblies

Cosmonaut v2.9.0
Microsoft.Azure.DocumentDB.Core v2.2.2
Microsoft.Azure.WebJobs.Extensions.CosmosDB v3.0.3
Microsoft.Azure.WebJobs.Extensions.SignalRService v1.0.0-preview1-10025
Microsoft.NET.Sdk.Functions v1.0.24

I believe this is related to a assembly version conflict with the Microsoft.Azure.DocumentDB.Core assembly and I am unable to downgrade due to the other package that I am using

Any ideas when you can bring the references more up to date?

Add backoff retry in queue based functions

The Azure Functions Service Bus and Storage Queue triggers have no sense of back off - so if you have a service bus message who's handler is failing (perhaps because a call to an external resource is failing) it gets pulled back through almost immediately - you can effectively end up "hammering on the door" of the external resource until the max retry count is reached.

A technique I've used to deal with this is to post a new message onto the service bus queue but with the enqueue visibility set to n seconds time and then allow the original message to be removed.

I'm considering codifying this in Function Monkey through an option on these trigger types.

Feedback welcome.

ILogger and DI Container

I didn't see anything in the samples where an ILogger can be added to the DI Container. I am aware that the Functions runtime does this by default but can you provide direction on how to configure for handlers and commands, etc.?

Accessing FORM in a HttpPost

I am looking to get hold of the form object from the HTTP request (reqest.Form.Files)to be able to get a file that is being sent to a function. We currently get this through the request in the function call and im unsure on how to map this to a Command. Help appreciated!
Thanks

Shaun

IHttpResponseHandler isn't compatible with ICommand commands without result.

if projects has a command with ICommand without TResult

public class UpdateCatalogCommand : ICommand

Project isn't compiled. It says:

Unhandled Exception: FunctionMonkey.ConfigurationException: CS0311:The type 'Todd.IO.Catalog.WebApi.Commands.UpdateCatalogCommand' cannot be used as type parameter 'TCommand' in the generic type or method 'ExceptionResponseHandler.CreateResponse<TCommand, TResult>(TCommand, TResult)'. There is no implicit reference conversion from 'Todd.IO.Catalog.WebApi.Commands.UpdateCatalogCommand' to 'AzureFromTheTrenches.Commanding.Abstractions.ICommand<FunctionMonkey.Abstractions.ISerializer>'. SourceFile([4580..4610))CS0311:The type 'Todd.IO.Catalog.WebApi.Commands.DeleteCatalogCommand' cannot be used as type parameter 'TCommand' in the generic type or method 'ExceptionResponseHandler.CreateResponse<TCommand, TResult>(TCommand, TResult)'. There is no implicit reference conversion from 'Todd.IO.Catalog.WebApi.Commands.DeleteCatalogCommand' to 'AzureFromTheTrenches.Commanding.Abstractions.ICommand<FunctionMonkey.Abstractions.ISerializer>'. SourceFile([4159..4189))
4> at FunctionMonkey.Compiler.Implementation.AssemblyCompiler.CompileAssembly(IReadOnlyCollection1 syntaxTrees, IReadOnlyCollection1 externalAssemblyLocations, OpenApiOutputModel openApiOutputModel, String outputBinaryFolder, String outputAssemblyName, String assemblyNamespace, TargetEnum target)
4> at FunctionMonkey.Compiler.Implementation.FunctionCompiler.Compile() in /Users/jamesrandall/code/myOpenSource/functionMonkey/Source/FunctionMonkey.Compiler/Implementation/FunctionCompiler.cs:line 94
4> at FunctionMonkey.Compiler.Program.Main(String[] args) in /Users/jamesrandall/code/myOpenSource/functionMonkey/Source/FunctionMonkey.Compiler/Program.cs:line 47

Errors in several handlebars templates

First. I love this project!

I dont know if I am doing something wrong, or missing something, but:
When I try to compile with timer or queue functions, it fails during the FunctionMonkeyCompiler, complaining: The type or namespace name 'ValidationException' does not exist in the namespace 'FunctionMonkey.Abstractions.Validation'. I searched through the repo and found that class in FunctionMonkey.Commanding.Abstractions.Validation (Commanding added), pulled, changed the templates and recompiled.

timer.csharp.handlebars
servicebusqueue.csharp.handlebars
servicebussubscription.csharp.handlebars
eventhubqueue.csharp.handlebars
storageblob.csharp.handlebars
storagequeue.csharp.handlebars

That error went away, but then it started complaining about messageId not being found. It seems messageId made it into some of the validation exception messages where it wasnt defined in the method signature.

timer.csharp.handlebars
eventhubqueue.csharp.handlebars
storageblob.csharp.handlebars
storagequeue.csharp.handlebars

Improved MSBuild Integration

Currently the Function Monkey compiler runs as a console app invoked via a target in the MSBuild chain. When an error is encountered it throws out an exception that gets logged in the output window but its really less than ideal - on Mac or Linux you can also end up with a system style dotnet exception.

I'd like to wrap the compiler in an MSBuild task that better integrates into the build chain.

https://docs.microsoft.com/en-us/visualstudio/msbuild/task-writing?view=vs-2017

Not something I've done before, if anyone has any best practice or hints and tips I'd love to hear them.

Unable to cast Object of type(...) to ICommandHandler

Following your recent Part 1 video on using FunctionMonkey and once I have a simple structure created to verify the plumbing works, I get the following error:

[3/17/19 2:00:58 AM] AzureFromTheTrenches.Commanding: Error occurred during command execution. Anonymously Hosted DynamicMethods Assembly: Unable to cast object of type 'ThreeWill.Functions.Application.Handlers.HelloWorldCommandHandler' to type 'AzureFromTheTrenches.Commanding.Abstractions.ICommandHandler`2[ThreeWill.Functions.Commands.HelloWorldCommand,System.String]'.``` 

Using the v1.0.0 versions of FunctionMonkey an FunctionMonkey.Compiler.  
Using v9.0.1 of the Commanding Abstractions.  
Azure Functions Core Tools 2.4.401
Function Runtime Version: 2.0.12309.0

Have you seen this before?  Both macOS w/ VS Code and VS 2017 enterprise get the same result.  Debugging does not seem to get past some of the Function framework prices, or maybe I am missing a way to debug into the actual issue.  

I'll keep digging, but thought I would ask if this might be something simple.  

Compiling bug

I was follwing steps in this tutorial. I tried the build the app and I ended up with error.

Severity Code Description Project File Line Suppression State
Error MSB3073 The command "dotnet "C:\Users\Jan Skála.nuget\packages\functionmonkey.compiler\0.10.1-beta000\build\netstandard1.0....\tools\netcoreapp2.0/FunctionMonkey.Compiler.dll" C:\Users\Jan Skála\Documents\Visual Studio 2017\Projects\Talxis\Functions\Premiere.Function\bin\Debug\netstandard2.0\bin\Premiere.Function.dll" exited with code -532462766. Premiere.Function C:\Users\Jan Skála.nuget\packages\functionmonkey.compiler\0.10.1-beta000\build\netstandard1.0\FunctionMonkey.Compiler.targets 10

Output:

Unhandled Exception: System.FormatException: String was not recognized as a valid Boolean.
1> at System.Boolean.Parse(String value)
1> at FunctionMonkey.Compiler.Program.Main(String[] args) in D:\wip\myOpenSource\functionMonkey\Source\FunctionMonkey.Compiler\Program.cs:line 22

Nugets:

  • FunctionMonkey 0.10.0-beta000
  • FunctionMonkey.Compiler 0.10.1-beta000

How to add Auditing in FunctionMonkey?

Hi James

Thanks for building this framework, appreciate the effort and good thinking.

I have a question regarding Auditing ability shown in this article.

I presume that I need the ICommandingDependencyResolverAdapter resolver or ICommandRegistry registry so I can add the Pre, Post and Execute Dispatch hooks. Is there a way that I can do it in FunctionAppConfiguration currently?

Thanks!

JSON.NET DefaultContractResolver

Hello

Do you mind, turning off the CamelCasePropertyNamesContractResolver() in method - CreateResponse in the file: http.csharp.handlebars?

So that we can change the JSON.NET default DefaultContractResolver to apply a different behavior for all the API.

Thanks
Kris

Missing "}" in output file.

After merging PR today output Function cs file has error. For example:

            Microsoft.Extensions.Primitives.StringValues queryParameterValues;
            string method = req.Method.ToUpper();
            if (method == "GET" || method=="DELETE")
            {
                        if (req.Query.TryGetValue("Id", out queryParameterValues))
                        {
                            {
                                {
                                    System.Nullable<System.Guid> nullableValue;
                                    if(TryParseNullable(queryParameterValues[0], System.Guid.TryParse, out nullableValue))
                                    {
                                        command.Id = nullableValue;
                                    }
                                }
                            }
                        }
                        if (req.Query.TryGetValue("Name", out queryParameterValues))
                        {
                            command.Name = queryParameterValues[0];
                        }
                        if (req.Query.TryGetValue("Order", out queryParameterValues))
                        {
                            {
                                FunctionApp1.SortOrder result;
                                if (System.Enum.TryParse<FunctionApp1.SortOrder>(queryParameterValues[0], out result))
                                {
                                    command.Order = result;
                                }
			}

            }

It seems that missed "}" at last line

Access to ExecutionContext in ITokenValidator implementation

At present the http.csharp.handlebars template only sets up the Context Setter just prior to executing the Command. It would be extremely useful to have access to the Context from inside the ITokenValidator.ValidateAsync method.

If we moved the code that sets the Execution Context (currently line 118) to an earlier point (say Line 40) then the execution context would be available to all the code that runs from there on out .

No job functions found.

Hi James. I've cloned the full FunctionMonkey solution locally and have set GettingStartedSample project as the startup project. I've done no other modifications to the source code and configuration. When running the project I get the following message in the function runtime terminal (version 2.0.12134.0):

"No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.)."

As a result no URL is provided for running the application. Could that be related to the changes in the Functions runtime since the latest version of FunctionMonkey was released?

How to download a zip file

How can I set up a function that will download a Zip file to the client when completed?

I have a function that will generate multiple PDF documents and would like to return a Zip file container each of the created PDF documents to the client, do you have any examples?

How to add SignalR binding

Thanks for the framework, love and keep up the good work.

I have a question though about how to add SignalR input binding to a function, for example if I create a standard function I can add [SignalR(HubName = "assessments")] IAsyncCollector<SignalRMessage> signalRMessages in the function which then allows me to send events using WebSockets

I cannot seem to find a way to do this with FunctionMonkey, if I add this to the ExecuteAsync method I get a compile error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.