Azure SQL UserTokenCaches在本地工作,但未部署

时间:2018-09-25 19:58:55

标签: c# azure azure-sql-database

我正在使用Azure AD进行身份验证。我可以理解为用户可以使用其凭据登录,但是当我去拉用户令牌以将其发送到Graph API进行身份验证时,它说它找不到我的令牌。奇怪的是,我在本地将我的ApplicationDbContext指向Azure SQL中的一个数据库,并且更新UserTokenCaches表没有问题,但是一旦我部署到我的Web应用程序后,它似乎不再找到该数据库并且UserTokenCaches表永远不会更新。 / p>

这是我也缩小范围的方法。当由于某种原因在本地调用db.UserTokenCacheList时,它可以连接到Azure SQL,但是当部署到Azure Web应用程序时,它不再可以。

    public ADALTokenCache(string signedInUserId)
    {
        // Associate the cache to the current user of the web app
        userId = signedInUserId;
        this.AfterAccess = AfterAccessNotification;
        this.BeforeAccess = BeforeAccessNotification;
        this.BeforeWrite = BeforeWriteNotification;
        // Look up the entry in the database
        Cache = db.UserTokenCacheList.FirstOrDefault(c => c.webUserUniqueId == userId);
        // Place the entry in memory
        this.Deserialize((Cache == null) ? null : MachineKey.Unprotect(Cache.cacheBits,"ADALCache"));
    }

0 个答案:

没有答案
相关问题