Loading data regularly–deploy plugins–Azure Function–part 34
Now I have broken the build. Why ?Because of the docker file – to be optimized on local, I copy ecah csproj one by one and the I do dotnet restore. (If docker had a glob patttern! ) . So each time that I put a new project, the build will fail!
Trying now from the Azure Function to load the plugins . Apparently, the deploying does not deploy also the plugins ( Application Insights , connected to the Azure function ,is your friend – it can show you all kind of messages)
But now I have a problem copying the plugins. I do in azure Function like I have done with the other projects;
A post-build event
dotnet pwsh $(ProjectDir)preBuild.ps1 “$(RepoRoot)plugins\” “$(TargetDir)”
and a file prebuild.ps1 file that says
echo “args 0 ” $args[0]
echo “args 1 ” $args[1]
$a= Get-Location
echo $a
echo now copy
Copy-Item -Path $args[0] -Destination $args[1] -Recurse -Force
For all other projects it is working. For the azure function, it gives an error at the compiling time on CI ( not on local! )
/bin/sh: 3: /tmp/tmpdd44ee8bfe4f49dca815035fe3a451ee.exec.cmd: Syntax error: Unterminated quoted string
I found the problem
dotnet pwsh $(ProjectDir)preBuild.ps1 “$(RepoRoot)plugins\” “$(TargetDir)”
Now, a different error raises on Github CI when compiling the Azure Function:
The specified framework ‘Microsoft.NETCore.App’, version ‘2.1.0’ was not found.
The problem is here: https://github.com/Azure/azure-functions-vs-build-sdk/blob/master/src/Microsoft.NET.Sdk.Functions.MSBuild/Targets/Microsoft.NET.Sdk.Functions.targets
<_FunctionsTaskFramework Condition=” ‘$(MSBuildRuntimeType)’ == ‘Core'”>netcoreapp2.1</_FunctionsTaskFramework>
I try to build into an netcoreapp3.0 docker container. I must install 2.1, probably.
For github actions:
– name: Setup .NET Core 2.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: 2.1.802– name: Setup .NET Core 3.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.0.100
Not working!
But a new idea – what if I have the project not up-to-date ? And indeed , the nuget for azure functions was not update. Now it works for GitHub actions!https://github.com/ignatandrei/InfoValutar/actions
Now , back to work – I want to deploy the plugins in the Azure Function
Reading about ExecutionContext – ok. Reading about difference between FunctionAppDirectory and FunctionDirectory –https://github.com/Azure/azure-functions-host/wiki/Retrieving-information-about-the-currently-running-function . Ok – I want FunctionDirectory – I think it is just for this function.
For uploading files and folder, there are 2 ideas:
- to have included in .csproj ( do not want the plugins to be included !)
- To include in the zip file https://docs.microsoft.com/en-us/azure/azure-functions/deployment-zip-push
So CI / CD to the rescue. I will do in AzureDevOps – next time!
Infovalutar
And one hour passes...(This is the result of 1 hour per day auto-challenge as a full cycle developer for an exchange rates application)
( You can see the sources at https://github.com/ignatandrei/InfoValutar/ )