2

I have created an Azure Function application in Visual Studio 2017 and can publish it to Azure without any issues using the Visual Studio publish functionality (right click project then select Publish).

As deploying from a developers instance of Visual Studio isn't an ideal continuous integration strategy, I have created a deployment pipeline with TeamCity and Octopus where TeamCity builds the Azure function application and Octopus uses the WAWSDeploy application to deploy the Azure Function files to Azure. The deployment works fine and I when I view the Azure function files when deployed via WAWSDeploy, the files are exactly the same as when I publish the Azure Function application from Visual Studio.

However I get the errors No job functions found. Try making your job classes and methods public. and Invalid script file name configuration. The 'scriptFile' property is set to a file that does not exist. when I deploy (by viewing the Azure Function application logs) from WAWSDeploy. This doesn't appear to be a WAWSDeploy issue but it looks like the Visual Studio publish function is doing something I'm missing. Any ideas?

Folder structure of Azure function files:

enter image description here

dhughes
  • 645
  • 1
  • 7
  • 19
  • Can you share your folder structure (with the location of your function assembly) and the value you have in the `scriptFile` property? – Fabio Cavalcante Jun 20 '17 at 05:19
  • @FabioCavalcante I have edited my question to include my function file structure. I am unable to find the `scriptFile` property and have not set/updated it previously. Where can I find it? – dhughes Jun 20 '17 at 10:13
  • `scriptFile` should be a property in the function.json file. – brettsam Jun 20 '17 at 14:04
  • Thanks @brettsam - you have help me solve the problem I think. When I publish the Azure function, the `scriptFile` value is `..\\bin\\myFunction.dll` but when I build then deploy, the `scriptFile` value is `..\\myFunction.dll`. @FabioCavalcante - why do publish and build generate different `scriptFile` values? – dhughes Jun 20 '17 at 23:05
  • 1
    I can confirm this resolves the issue. I have made a hack in my Powershell script to set the correct `scriptFile` value. – dhughes Jun 21 '17 at 01:45
  • Glad that resolved the problem. Without more context on how this was deployed it's hard to say what went wrong. – Fabio Cavalcante Jun 21 '17 at 03:17
  • I had the same output while trying to run my function locally. I changed the assembly name and for some reason VS was using my old function name. Clean + Rebuild did the trick and in the file "bin\Debug\net461\myFunction\function.json", the scriptFile value "../bin/oldAssemblyName.dll" became "../bin/newAssemblyName.dll" – Dreeco Jan 25 '18 at 11:53

3 Answers3

2

I faced the same issue,

I deleted the bin and obj folders and rebuilt the project and it works perfectly then.

Manthan Devani
  • 179
  • 2
  • 4
1

Issue was caused by having an incorrect scriptFile value in the function.json file. When I published the Azure function from Visual Studio, this value is set correctly but when I build the Azure function and push the files to the Azure function application manually, the scriptFile value is missing the bin folder in the path to my function dll file. During my build process, I now hack the scriptFile value to set it correctly.

dhughes
  • 645
  • 1
  • 7
  • 19
0

I faced similar issues and finally managed to found the root cause. You may fixed this problem, but putting this here for anyone else facing this problem.

Ensure you have this following block of element in your .csproj in of a Function App

<None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

I got this problem when i excluded host.json from the project and then created one again (after realizing this is needed for sure).

valid .csproj should look something like this

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net461</TargetFramework>
  </PropertyGroup>

  ...
  ...
  ...

  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>

Hopefully Adding that will solve this issue. Let me know if this helps :)

Shunmugam V
  • 73
  • 1
  • 8