gpt4 book ai didi

azure - 在 Azure 上的 GitHub 工作流中应用 EF 迁移

转载 作者:行者123 更新时间:2023-12-03 01:59:35 26 4
gpt4 key购买 nike

我有一个 webapi,我在其中使用迁移来更新数据库,但是当我添加到 github 操作时:

- name: Database update
run: |
dotnet tool install --global dotnet-ef
dotnet tool restore
dotnet ef database update -c MyContext -p ./MyProject.WebApi

要运行迁移,它会因错误而崩溃:

Error Number:-1983577849,State:0,Class:20 A network-related orinstance-specific error occurred while establishing a connection toSQL Server. The server was not found or was not accessible. Verifythat the instance name is correct and that SQL Server is configured toallow remote connections. (provider: SNI_PN11, error: 50 - LocalDatabase Runtime error occurred. The specified LocalDB instance doesnot exist.)

我唯一能想到的是我应该设置连接到数据库的IP,但我不知道构建从哪个IP运行..或者Azure中是否有某个地方可以将其设置为从 github 连接到数据库?

PS:我使用的连接字符串是直接从Azure门户复制的

最佳答案

正如您提到的,这可能是允许从 Github Runners 访问您的数据库的情况。

可以将其列入白名单。但这个名单真的很长。

请看一下here - About GitHub's IP addresses 。需要将操作部分中的所有地址添加到您的防火墙设置中。

这是 github api https://api.github.com/meta 的链接

"actions": [
"4.148.0.0/16",
"4.149.0.0/18",
"4.149.64.0/19",
"4.149.96.0/19",
"4.149.128.0/17",
"4.150.0.0/18",
"4.150.64.0/18",
"4.150.128.0/18",
"4.150.192.0/19",
"4.150.224.0/19",
.....

如果您使用 Azure SQL 数据库,您可以考虑类似的方法,如 here for App Services

关于azure - 在 Azure 上的 GitHub 工作流中应用 EF 迁移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76843551/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com