【问题标题】:Azure functions and ASP.NET membershipAzure 函数和 ASP.NET 成员资格
【发布时间】:2018-04-24 15:13:30
【问题描述】:

我有一个清理非活动用户数据库的 Azure 函数。此清理涉及删除 ASPNET Membership 条目,方法是:

System.Web.Security.Membership.DeleteUser(username);

问题在于 ASPNET Membership 框架需要 app.config/connection.config 文件中的连接字符串(请参阅https://msdn.microsoft.com/en-us/library/6e9y4s5t.aspx)。

我已将包含必要信息的 app.config 文件添加到我的 Azure 函数中,但这不起作用。我得到下一个错误:

System.Configuration.Provider.ProviderException: 'The connection name >'LocalSqlServer' was not found in the applications configuration or the>connection string is empty.'

您对如何实现这一点有任何想法吗?

【问题讨论】:

    标签: c# azure asp.net-membership azure-functions


    【解决方案1】:

    因此,根据 Microsoft 关于 Azure Functions 的文档,“函数应用在 Azure 中托管函数的执行。在函数应用设置中存储连接字符串和其他机密是最佳做法。”

    您可以查看下面的示例,该示例实现了与您正在执行的操作非常相似的功能。

    在 Azure 门户中添加连接字符串,方法是转到 Azure Function App 并选择 Platform Features 然后选择 Application settings 并将条目添加到 Connection Strings 部分。

    Azure Function App example

    【讨论】:

    • 当然,在生产中我会在你提到的地方添加连接字符串。但首先我想在本地测试它,在这种情况下,我需要在某个文件中指定连接字符串。第二个问题是,据我目前所见,ASPNET Membership 需要这个 app.settings,而该功能根本不可用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-24
    • 2011-02-03
    相关资源
    最近更新 更多