Oryx
Oryx copied to clipboard
[docs] How to deploy Entity Framework Core Migrations?
Feature Request
May you please clarify how to deploy Entity Framework Core migrations with ASP.net CORE MVC?
I'm trying customizing the appsvc.yaml with many different commands but no success.
Right now my appsvc.yaml is like this:
version: 6
pre-build: |
export PATH="$PATH:/home/.dotnet/tools"
post-build: |
dotnet --list-sdks
echo $DOTNET_ROOT
dotnet ef database update
The error I get is this:
A fatal error occurred. The required library libhostfxr.so could not be found.
But I've set the DOTNET_ROOT environment variable with the result of dotnet --list-sdks
The build result is like this:
$ git push azure master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 343 bytes | 343.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Deploy Async
remote: Updating branch 'master'.
remote: Updating submodules.
remote: Preparing deployment for commit id '173d216bd9'.
remote: PreDeployment: context.CleanOutputPath False
remote: PreDeployment: context.OutputPath /home/site/wwwroot
remote: Repository path is /home/site/repository
remote: Running oryx build...
remote: Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
remote: You can report issues at https://github.com/Microsoft/Oryx/issues
remote:
remote: Oryx Version: 0.2.20220308.4, Commit: c92fa6a2d6fc14dc9646f80e2bb2e393a5cdc258, ReleaseTagName: 20220308.4
remote:
remote: Build Operation ID: |b07glt+cFxY=.56eee8f7_
remote: Repository Commit : 173d216bd9482b40d1139bc69bb29bee2d2b65ff
remote:
remote: Detecting platforms...
remote: ....
remote: Detected following platforms:
remote: dotnet: 6.0.6
remote:
remote: Found BuildConfigurationFile
remote: Overriding the pre-build commands with the BuildConfigurationFile section
remote: export PATH="$PATH:/home/.dotnet/tools";
remote: Overriding the post-build commands with the BuildConfigurationFile section
remote: dotnet --list-sdks;echo $DOTNET_ROOT;dotnet ef database update
remote:
remote: Using intermediate directory '/tmp/8da7e59f58f9ca7'.
remote:
remote: Copying files to the intermediate directory...
remote: Done in 2 sec(s).
remote:
remote: Source directory : /tmp/8da7e59f58f9ca7
remote: Destination directory: /home/site/wwwroot
remote:
remote: Executing pre-build command...
remote: Finished executing pre-build command.
remote:
remote: Using .NET Core SDK Version: 6.0.301
remote: Determining projects to restore...
remote: .
remote: Restored /tmp/8da7e59f58f9ca7/src/AssistenciaSocial.PontuaCasos.WebApp/AssistenciaSocial.PontuaCasos.WebApp.csproj (in 3.97 sec).
remote:
remote: Publishing to directory /home/site/wwwroot...
remote:
remote: Microsoft (R) Build Engine version 17.2.0+41abc5629 for .NET
remote: Copyright (C) Microsoft Corporation. All rights reserved.
remote:
remote: Determining projects to restore...
remote: All projects are up-to-date for restore.
remote: .....................................
remote: AssistenciaSocial.PontuaCasos.WebApp -> /tmp/8da7e59f58f9ca7/src/AssistenciaSocial.PontuaCasos.WebApp/bin/Release/net6.0/AssistenciaSocial.PontuaCasos.WebApp.dll
remote: ..
remote: AssistenciaSocial.PontuaCasos.WebApp -> /home/site/wwwroot/
remote:
remote: Executing post-build command...
remote: 6.0.301 [/tmp/oryx/platforms/dotnet/6.0.301/sdk]
remote: /tmp/oryx/platforms/dotnet/6.0.301/sdk
remote: A fatal error occurred. The required library libhostfxr.so could not be found.
remote: If this is a self-contained application, that library should exist in [/home/.dotnet/tools/.store/dotnet-ef/6.0.8/dotnet-ef/6.0.8/tools/net6.0/any/].
remote: If this is a framework-dependent application, install the runtime in the global location [/usr/share/dotnet] or use the DOTNET_ROOT environment variable to specify the runtime location or register the runtime location in [/etc/dotnet].
remote:
remote: The .NET runtime can be found at:
remote: - https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=debian.10-x64&apphost_version=6.0.6
remote:
remote: Generating summary of Oryx build
remote: Parsing the build logs
remote: Found 0 issue(s)
remote:
remote: Build Summary :
remote: ===============
remote: Errors (0)
remote: Warnings (0)
remote:
remote: Deployment Failed.
remote: Deployment Logs : 'https://pontuacasos.scm.azurewebsites.net/newui/jsonviewer?view_url=/api/deployments/173d216bd9482b40d1139bc69bb29bee2d2b65ff/log'
To https://pontuacasos.scm.azurewebsites.net/pontuacasos.git
1702ec2..173d216 master -> master
@robertoosantos Hey Roberto, are you able to provide a link to the application you're attempting to deploy? If not, what is the TargetFramework
in the .csproj
corresponding to your application? This may be an issue with the SDK on-disk that's trying to eb used when looking for libhostfxr.so
, but I'd like to double-check locally and repro this issue myself.
In fact, I've learned that it's a bad practice to apply migrations on production directly, as instead we should generate an idempotent SQL script as documented here: Applying Migrations - Idempotent SQL scripts