-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EF Core tools does not work in combination with Azure KeyVault #26665
Comments
Where is the value of "ValutUri" set? |
I have removed the actual keyvault URI as well as the db connection string (as it was tied to my work azure acc) you can hardcode it in the format of https://.vault.azure.net/ and you can use any azure keyvault and whatever is stored there isn't important. |
@zyofeng What is the actual code for this line? builder.Configuration.AddAzureKeyVault(new Uri("VaultUri"), new DefaultAzureCredential()); Obviously, this is going to fail. But I assume you actually have some code that reads the URI from somewhere. Presumably, the configuration? What does that code look like? Also, what is the actual exception message and stack trace? (You can get this by running the |
For this example Im hardcoding it, you can replace it with your own uri. Here is the error Im getting add-migration Init -verbose |
If I comment this line out //builder.Configuration.AddAzureKeyVault(new Uri("https://ef-core-migration.vault.azure.net/"), new DefaultAzureCredential()); The migrations are generated correctly Using project 'NZFM.Common.Web'. |
No difference using dotnet ef migrations PM> dotnet ef migrations add Init --verbose Build succeeded. C:\Users\zyofe\source\repos\zyofeng\keyvault-ef-migration\TestDbContext.cs(15,23): warning CS8618: Non-nullable property 'Description' must contain a non-null value when exiting constructor. Consider declaring the property as nullable. [C:\Users\zyofe\source\repos\zyofeng\keyvault-ef-migration\NZFM.Common.Web.csproj] Time Elapsed 00:00:01.07 |
@zyofeng This looks like a timeout issue, which is fixed in 6.0.1 by dotnet/runtime#60891 |
I am on version 6.0.1 using azure keyvault and azure appconfiguration to manage my secrets and I am still getting this issue:
Is there a way to extend the timeout, or it that update coming out with a |
@ghorsey How/from where did you get 6.0.1? |
I am sometimes thick when coding too late into the evening. I was thinking dotnet-ef 6.0.1 came with dotnet SDK 6.0.100 After a full nights sleep, I realize my mistake :) |
In case someone is running into a similiar error when trying to use Entity Framework Core with Migrations + connection string in a Key vault, where the value of the value is stored in an environment variable. It seems that when running from the package manager console to create migrations, the environment variable is not set. Based on https://stackoverflow.com/a/54289077/225808,
|
If I add AzureKeyVault using the standard Azure.Extensions.AspNetCore.Configuration.Secrets library as below
builder.Configuration.AddAzureKeyVault(new Uri("VaultUri"), new DefaultAzureCredential());
add-migration will fail to generate any migration code
An error occurred while accessing the Microsoft.Extensions.Hosting services. Continuing without the application service provider. Error: Value cannot be null. (Parameter 'uriString')
Commenting out the AddAzureKeyVault line and everything works.
Repo replicating the issue
https://github.com/zyofeng/keyvault-ef-migration
The text was updated successfully, but these errors were encountered: