-1

I have to integrate a third-party command-line tool within existing azure functions. I saw a couple of questions (like this one) and blogs with example how can we call exe from azure functions by uploading exe file from the azure portal and execute from code.

Is uploading from portal is the only way of uploading exe? Problem with this approach is that I need manually upload the file after every time I deploy code from visual studio because all files are beeing removed. Is there any way I can simply keep it unchanged or make it part of my project so the exe and its dependency files (not assemblies but internal files it references) or is there a way I can automate this to copy/upload to azure functions.

I am using App Service plan instead of consumption plan which I understand has some flexibility and control over the host.

dejjub-AIS
  • 1,501
  • 2
  • 24
  • 50

1 Answers1

0

In your Azure Pipeline, you could simply copy any files you need along with your function app before archiving the publish folder.

For example, if you are following the official docs, you could copy the files you need to the publish directory (or even run a script if you need to fetch them from somewhere) before the ArchiveFiles@2 task.

Building on top of the sample azure pipeline in the docs, something like this should do

pool:
      vmImage: 'VS2017-Win2016'
steps:
- script: |
    dotnet restore
    dotnet build --configuration Release
- task: DotNetCoreCLI@2
  inputs:
    command: publish
    arguments: '--configuration Release --output publish_output'
    projects: '*.csproj'
    publishWebProjects: false
    modifyOutputPath: true
    zipAfterPublish: false
- task: ShellScript@2
  inputs:
    scriptPath: 'fetch-3rd-party-files.sh'
- task: ArchiveFiles@2
  displayName: "Archive files"
  inputs:
    rootFolderOrFile: "$(System.DefaultWorkingDirectory)/publish_output"
    includeRootFolder: false
    archiveFile: "$(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip"
- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip'
    name: 'drop'

Also, if required, you could directly integrate the copy task in your csproj file as well. Something like this should do (refer this answer for more details)

<Project Sdk="Microsoft.NET.Sdk">
  ...
  <Target Name="CopyFiles" AfterTargets="Publish">
    <Copy 
      SourceFiles="random.dat"
      DestinationFolder="$(PublishDir)\data_files\"
    />
  </Target>
  ...
</Project>

Check the reference to the Copy Task used above for available options.

PramodValavala
  • 6,026
  • 1
  • 11
  • 30