1
votes

In my ARM template i have piece of code:

  "name": "[variables('logicappname')]",
  "type": "Microsoft.Logic/workflows",
  "location": "[resourceGroup().location]",
  "apiVersion": "2016-06-01",
  "dependsOn": [
    "[resourceId('Microsoft.Web/connections', variables('servicebusConnectionName'))]",
    "[resourceId('Microsoft.Web/sites/sourcecontrols', variables('functionAppName'), 'web')]"
  ],
  "tags": {
    "displayName": "display-name"
  },

And in resources array:

    {
      "apiVersion": "2015-08-01",
      "name": "web",
      "type": "sourcecontrols",
      "dependsOn": [
        "[resourceId('Microsoft.Web/Sites', variables('functionAppName'))]"
      ],
      "properties": {
        "RepoUrl": "[parameters('repoURL')]",
        "branch": "[variables('branch')]",
        "IsManualIntegration": true
      }
    }

variables('branch') = 'master-dev'

variables('repoUrl') = https://user:[email protected]/DefaultCollection/PROJECTNAME/_git/REPO

In my repo I have azure functions project, which has this structure:

  • function-1, function-1/function.json, function-1/run.csx
  • function-2, function-2/function.json, function-2/run.csx
  • .gitignore
  • .appsettings.json
  • host.json
  • local.settings.json
  • read_me.html
  • README.md

In this case everything works well.

Now I need to create few new projects in the same solution - Core, tests.

The structure now looks like that (let's ignore the tests proj):

  • Core
  • Core/Properties/AssemblyInfo.cs
  • Core/bin/Debug/Core.dll
  • Core/Core.csproj
  • OrdersService.cs
  • function-1, function-1/function.json, function-1/run.csx
  • function-2, function-2/function.json, function-2/run.csx
  • .gitignore
  • .appsettings.json
  • host.json
  • local.settings.json
  • read_me.html
  • README.md

Once i have Core.dll which has some code I can include the dll in my function-1 (run.csx):

#r ".\..\Core\bin\Debug\Core.dll"

public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
    var service = Core.OrdersService.GetInstance();
    return req.CreateResponse(HttpStatusCode.OK, service.GetOrderHistory());
}

Now when I deploying the azure function into the portal (by current arm template) I can't finish deployment. I have an error that the function "function-1" doesn't exist. When I go to the portal it's the same - the azure function has been created, but inside the function, there are no any methods.

P.S. Changes on local work well - I can call endpoints http://localhost:7071/api/function-1 (in debug and normal mode).

I guess, the problem is with "Core" folder, which does not match an azure function/method and by this way, i can't publish my repo into the azure portal.

My questions:

  1. It's possible to specify in a repoUrl or by Microsoft.sourcecontrols resource, that I want to create Azure functions with some method, but from a specified subfolder? By this way, i'll solve it, just by copying the azure function project into the specific folder and then start to use them in azure function.

  2. It's possible to specify that I want to use some specific files/folders in deployment from my VSO repo into the azure function?

1

1 Answers

1
votes

My first suggestion would be that you can move to just using class libraries for everything. .csx is only needed if you want the ability to edit in the portal, but you can use normal .dll's for your functions. Check out this blog post: https://blogs.msdn.microsoft.com/webdev/2017/11/15/improvements-to-azure-functions-in-visual-studio/

Git deploy will copy all files over, so not sure why it's not including everything.

If you could share your exact error logs you see from the deployment, that'd help to debug this specific case, but I think the new VS tooling would have a cleaner experience for you than just using C# script.