Azure应用服务:多个应用可以连接到单个后端吗?

时间:2017-11-27 10:04:48

标签: azure xamarin f# azure-web-sites

我正在构建一个由三个不同应用组成的应用生态系统。它们都共享相同的域模型,但它们针对不同类型的用户。但是,用户数据库是共享的:如果您在一个应用程序中注册,则您已经有效地注册了这三个应用程序。

这是使用外部提供商登录的(共享)代码:

member __.SignInAsync (provider: MobileServiceAuthenticationProvider) (client:IMobileServiceClient) (oAuth2: OAuth2Parameters) =
    let completedToSignInResult (completed: AuthenticatorCompletedEventArgs) =
        match completed.IsAuthenticated with
        | true -> Authenticated completed.Account
        | false -> NotAuthenticated
    let failedToSignInResult (failed: AuthenticatorErrorEventArgs) =
        AuthenticationFailed(failed.Message, failed.Exception |> Some)
    let authenticator = createAuthenticator oAuth2
    let observable = authenticator.Completed.Select(completedToSignInResult).Merge(authenticator.Error.Select(failedToSignInResult)).FirstAsync()
    AuthenticationState.Authenticator <- authenticator;
    let presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter()
    presenter.Login authenticator
    async {
        try
            let! signInResult = observable |> TaskObservableExtensions.ToTask |> Async.AwaitTask
            match signInResult with
            | Authenticated account ->
                let token = new JObject()
                token.Add("access_token", JToken.FromObject(account.Properties.["access_token"]))
                let! user = client.LoginAsync(provider, token) |> Async.AwaitTask
                return ExternalLoginSucceeded user
            | NotAuthenticated -> return ExternalLoginFailed (String.Format(LocalisedStrings.ProviderSignInFailedTitle, provider), None)
            | AuthenticationFailed (m, e) -> return ExternalLoginFailed (m, e)
        with | ex -> 
            let logger = Locator.Current.GetService<ILog>()
            logger.Error Tag (sprintf "Unexpected sign-in failure with %O" provider) (Some ex)
            let message = String.Format(LocalisedStrings.ProviderSignInFailedTitle, provider)
            return ExternalLoginFailed (message, Some ex)
    }

从演示者检索的访问令牌是特定于应用程序的。但是,Azure门户仅允许我为每个应用服务注册一个Facebook或Google App ID和App Secret (参见屏幕截图)。

当然,我可以启动三种不同的应用服务,但这似乎是解决问题的一种非常昂贵的方式。有没有办法在一个服务中托管多个应用程序ID和应用程序机密,还是我受到架构的约束而花更多钱?

enter image description here

0 个答案:

没有答案