我这样ApplicationUserManager定义:
public class ApplicationUserManager : UserManager<ApplicationUser, int>
{
public ApplicationUserManager(IUserStore<ApplicationUser, int> store)
: base(store)
{
}
public override Task<IdentityResult> CreateAsync(ApplicationUser user, string password)
{
var result = base.CreateAsync(user, password);
//...
Repository.DoSomething(...); //Repository is null here
//..
}
[Dependency]
public IRepository Repository { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
出于某种原因,我的存储库没有被注入.Repository总是null
我的统一配置中也有这一行
.RegisterType<ApplicationUserManager>(new HierarchicalLifetimeManager())
Run Code Online (Sandbox Code Playgroud)
如何注射?
更新N:
这是我的控制器的代码; 我是怎么得到的UserManager:
public ApplicationUserManager UserManager
{
get
{
return _userManager ?? Request.GetOwinContext().GetUserManager<ApplicationUserManager>();
}
private set
{
_userManager = value;
} …Run Code Online (Sandbox Code Playgroud) dependency-injection unity-container asp.net-identity asp.net-web-api2
由于另一个NuGet包,我最近被迫将我的System.IdentityModel.Tokens.Jwt NuGet包更新到5.1.4.更改后的大多数代码似乎都很容易解决,但现在ConfigurationManager<OpenIdConnectConfiguration>()需要两个参数而不是一个!我找不到如何使用这个新版本的配置管理器的任何示例!
我将它用作此代码的一部分:
string stsDiscoveryEndpoint = string.Format("{0}/.well-known/openid-configuration", authority);
ConfigurationManager<OpenIdConnectConfiguration> configManager = new ConfigurationManager<OpenIdConnectConfiguration>(stsDiscoveryEndpoint, IConfigurationRetriever<>);
OpenIdConnectConfiguration config = await configManager.GetConfigurationAsync();
_issuer = config.Issuer;
_signingTokens = config.SigningTokens.ToList();
_stsMetadataRetrievalTime = DateTime.UtcNow;
Run Code Online (Sandbox Code Playgroud)
任何人都可以让我知道参数的ConfigurationManager预期
我正在尝试实施 Azure Durable Function 工作流。
每 6 分钟我就有一个 Azure TimerTrigger 函数调用一个 Azure 编排函数 (OrchestrationTrigger),它依次启动许多活动函数 (ActivityTrigger)。
然而,有时,Orchestration 函数会在几秒钟内被调用两次!这是一个大问题,因为我的活动函数不是幂等的!
下面是我的代码是如何被调用的。
定时器触发功能:
[FunctionName("StartupFunc")]
public static async Task Run([TimerTrigger("0 */6 * * * *", RunOnStartup = true, UseMonitor = false)]TimerInfo myStartTimer, [OrchestrationClient] DurableOrchestrationClient orchestrationClient, TraceWriter log)
{
List<OrchestrationModel> ExportModels = await getData();
string id = await orchestrationClient.StartNewAsync("OrchestratorFunc", ExportModels);
}
Run Code Online (Sandbox Code Playgroud)
编排功能:
[FunctionName("OrchestratorFunc")]
public static async Task<string> TransformOrchestration([OrchestrationTrigger] DurableOrchestrationContext context, TraceWriter log)
{
var dataList = context.GetInput<List<OrchestrationModel>>();
var tasks = new List<Task>();
foreach (var data in …Run Code Online (Sandbox Code Playgroud) 使用jwt.io验证我的Azure广告访问令牌时,我得到了无效签名。但是,我的ID令牌可以很好地验证!
在验证Azure广告访问令牌
和
https://nicksnettravels.builttoroam.com/post/2017/01/24/Verifying-Azure-Active-Directory-JWT-Tokens.aspx时,我已经看到并尝试了无效签名中建议的解决方案,
但是都不适合我的访问令牌。
访问和ID令牌是通过Adal.js生成的:
var endpoints = {
"https://graph.windows.net": "https://graph.windows.net"
};
var configOptions = {
tenant: "<ad>.onmicrosoft.com", // Optional by default, it sends common
clientId: "<app ID from azure portal>",
postLogoutRedirectUri: window.location.origin,
endpoints: endpoints,
}
window.authContext = new AuthenticationContext(configOptions);
Run Code Online (Sandbox Code Playgroud)
为什么我可以验证我的ID令牌,但不能验证我的访问令牌?
validation access-token oauth-2.0 azure-active-directory adal
我正在尝试使用持久函数进行一些数据转换。为此,我有一个 TimerTriggered 函数,它调用一个 Orchestration 函数,然后产生转换活动。
我的问题是,在调用 Orchestration 函数时,它会立即产生许多活动,甚至在到达启动该函数的代码部分之前。我的编排功能只应该启动 3 个活动,因为我的 dataList 只包含 3 个元素。
但是可以看出,在我下面包含的日志输出中,在调用编排函数后,在包含context.CallActivityAsync的循环开始之前,许多活动函数将立即运行
我根本找不到任何原因。在启动了这些许多活动之后,我的循环将实际运行并开始我期望的 3 个活动。
定时器触发功能:
[FunctionName("StartupFunc")]
public static async Task Run([TimerTrigger("0 */5 * * * *", RunOnStartup = true, UseMonitor = false)]TimerInfo myStartTimer, [OrchestrationClient] DurableOrchestrationClient orchestrationClient, TraceWriter log)
{
log.Info("*** STARTUP FUNCTION *** - Time triggered");
List<OrchestrationModel> ExportModels = await getData();
log.Info("** Orchestration Start **");
string id = await orchestrationClient.StartNewAsync("OrchestratorFunc", ExportModels);
log.Info("** Orchestration End **");
}
Run Code Online (Sandbox Code Playgroud)
编排功能:
[FunctionName("OrchestratorFunc")]
public static async Task<string> TransformOrchestration([OrchestrationTrigger] DurableOrchestrationContext …Run Code Online (Sandbox Code Playgroud) 我有一个 Azure 编排,其中触发编排的编排客户端引发了超时异常。
编排客户端功能只做两件事,启动两个编排,等待每个编排,正如大多数示例代码所建议的那样。
await orchestrationClient.StartNewAsync("TableOrchestrator", updates);
await orchestrationClient.StartNewAsync("ClientOrchestrator", clientExport);
Run Code Online (Sandbox Code Playgroud)
然而,据我了解,编排客户端并不是像编排功能那样的特殊功能,因此它最多只能运行10分钟。显然,我的两个编排的总运行时间很可能超过 10 分钟。
问题:
更新制作了我的代码功能和运行时的完整示例,如下所示。
看起来,如果之后编写了代码,则启动编排将等待它,但如果编排是最后一条语句,则不会!
更新的问题:
。
public static class testOrchestration
{
[FunctionName("Start")]
public static async Task Start([TimerTrigger("0 */30 * * * *", RunOnStartup = true, UseMonitor = false)]TimerInfo myStartTimer, [OrchestrationClient] DurableOrchestrationClient orchestrationClient, ILogger log)
{
var startTime = DateTime.Now;
log.LogInformation(new EventId(0, "Startup"), "Starting Orchestror 1 ***");
await orchestrationClient.StartNewAsync("Orchestrator", "ONE");
log.LogInformation($"Elapsed time, await ONE: {DateTime.Now - startTime}");
await Task.Delay(5000);
log.LogInformation($"Elapsed …Run Code Online (Sandbox Code Playgroud)