首页 > 解决方案 > .NET Core 3.0 Web 应用程序服务中具有个人帐户的数据库位于何处?

问题描述

我正在使用 Microsoft Identity 开发一个 .NET Core Web 应用程序。我已将其作为应用服务部署到 Azure 门户。我需要查看我已在 Microsoft Identity 中注册的用户,可能会删除其中的一些或进行修改,但我不知道数据库在云中的位置。任何人都可以帮忙吗?

编辑:这是 ConfigureServices() 方法:

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext<ApplicationDbContext>(options =>
                options.UseSqlite(
                    Configuration.GetConnectionString("DefaultConnection")));

            services.AddDefaultIdentity<ApplicationUser>()
                .AddEntityFrameworkStores<ApplicationDbContext>();

            services.AddIdentityServer()
                .AddApiAuthorization<ApplicationUser, ApplicationDbContext>();

            services.AddAuthentication()
                .AddIdentityServerJwt();

            services.AddControllersWithViews();
            services.AddRazorPages();

            services.AddSignalR().AddAzureSignalR(Configuration["SignalRConnectionString"]);

            // In production, the React files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/build";
            });

            // For scaffolding:
            services.AddMvc().AddControllersAsServices();

            var task = ConnectToEventHub();
            services.AddApplicationInsightsTelemetry();
        }

Edit2:我意识到我的问题是,这些用户以某种方式存储在一个数据库中,该数据库存储在一个名为 app.db 的文件中。该文件位于 Web 应用程序的根目录中。现在,这可以工作,但为了使其在生产环境中更有用,我的老板要求我将此数据库移动到 Azure SQL 数据库 - 或者基本上是用于我的 Web 应用程序的最简单和最便宜的数据库(其中作为应用服务托管在 azure 中)。Cosmos DB 过于昂贵,无法仅存储一张用户表。有人知道如何从 app.db 迁移到 Azure SQL 数据库之类的东西吗?

标签: asp.net-core.net-coreazure-web-app-serviceasp.net-core-3.0asp.net-core-identity

解决方案


与 Microsoft 身份相关的旧答案,而不是个人帐户

只需在 Azure 门户中查找 Azure Active Directory。您通常可以通过汉堡菜单访问它,或者只需在搜索框中键入 Azure Active Directory:

Azure 门户菜单

在 Azure Active Directory 窗格中,从“管理”部分的菜单中选择“用户”。有你的用户。

或者,您可以使用 Azure CLI 在 AAD 中查询用户。最简单的方法是直接在 Azure 门户中使用 Cloud Shell,因为它已经针对 Azure 进行了身份验证:

在此处输入图像描述

此外,请确保 AAD 租户 ID 与您在应用设置中使用的相同。

您的应用服务可能部署到连接到不同 AAD 的 Azure 订阅。

因此,例如我可以在我的私人订阅中创建应用服务,但我想让我公司的员工登录 -> 我在我公司的 AAD 中注册我的应用程序。


推荐阅读