void IExtensionConfigProvider.Initialize(ExtensionConfigContext context)
        {
            ConfigureLoaderHooks();

            context.ApplyConfig(this, "DurableTask");

            // Register the trigger bindings
            JobHostConfiguration hostConfig = context.Config;

            this.traceHelper    = new EndToEndTraceHelper(context.Trace);
            this.httpApiHandler = new HttpApiHandler(this, context.Trace);

            // Register the non-trigger bindings, which have a different model.
            var bindings = new BindingHelper(this, this.traceHelper);

            // For 202 support
            if (this.NotificationUrl == null)
            {
                this.NotificationUrl = context.GetWebhookHandler();
            }

            // Note that the order of the rules is important
            var rule = context.AddBindingRule <OrchestrationClientAttribute>()
                       .AddConverter <JObject, StartOrchestrationArgs>(bindings.JObjectToStartOrchestrationArgs);

            rule.BindToCollector <StartOrchestrationArgs>(bindings.CreateAsyncCollector);
            rule.BindToInput <DurableOrchestrationClient>(GetClient);

            context.AddBindingRule <OrchestrationTriggerAttribute>()
            .BindToTrigger(new OrchestrationTriggerAttributeBindingProvider(this, context, this.traceHelper));

            context.AddBindingRule <ActivityTriggerAttribute>()
            .BindToTrigger(new ActivityTriggerAttributeBindingProvider(this, context, this.traceHelper));
        }
        private void InitilizeBlobBindings(ExtensionConfigContext context)
        {
#pragma warning disable CS0618 // Type or member is obsolete
            Uri url = context.GetWebhookHandler();
#pragma warning restore CS0618 // Type or member is obsolete
            _logger.LogInformation($"registered http endpoint = {url?.GetLeftPart(UriPartial.Path)}");

            var rule = context.AddBindingRule <BlobAttribute>();

            // Bind to multiple blobs (either via a container; an IEnumerable<T>)
            rule.BindToInput <BlobContainerClient>(this);

            rule.BindToInput <MultiBlobContext>(this); // Intermediate private context to capture state
            rule.AddOpenConverter <MultiBlobContext, IEnumerable <BlobCollectionType> >(typeof(BlobCollectionConverter <>), this);

            // BindToStream will also handle the custom Stream-->T converters.
            rule.BindToStream(CreateStreamAsync, FileAccess.ReadWrite); // Precedence, must beat CloudBlobStream

            // Normal blob
            // These are not converters because Blob/Page/Append affects how we *create* the blob.
            rule.BindToInput <BlockBlobClient>((attr, cts) => CreateBlobReference <BlockBlobClient>(attr, cts));
            rule.BindToInput <PageBlobClient>((attr, cts) => CreateBlobReference <PageBlobClient>(attr, cts));
            rule.BindToInput <AppendBlobClient>((attr, cts) => CreateBlobReference <AppendBlobClient>(attr, cts));
            rule.BindToInput <BlobClient>((attr, cts) => CreateBlobReference <BlobClient>(attr, cts));
            rule.BindToInput <BlobBaseClient>((attr, cts) => CreateBlobReference <BlobBaseClient>(attr, cts));

            // CloudBlobStream's derived functionality is only relevant to writing. check derived functionality
            rule.When("Access", FileAccess.Write).
            BindToInput <Stream>(ConvertToCloudBlobStreamAsync);

            RegisterCommonConverters(rule);
            rule.AddConverter(new StorageBlobConverter <BlobClient>());
        }
        public void Initialize(ExtensionConfigContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            StaticServiceHubContextStore.ServiceManagerStore = serviceManagerStore;

            Exception webhookException = null;

            try
            {
                var url = context.GetWebhookHandler();
                logger.LogInformation($"Registered SignalR trigger Endpoint = {url?.GetLeftPart(UriPartial.Path)}");
            }
            catch (Exception ex)
            {
                webhookException = ex;
            }

            JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
            {
                Converters = new List <JsonConverter>()
                {
                    new ServiceEndpointJsonConverter()
                }
            };

            context.AddConverter <string, JObject>(JObject.FromObject)
            .AddConverter <SignalRConnectionInfo, JObject>(JObject.FromObject)
            .AddConverter <JObject, SignalRMessage>(input => input.ToObject <SignalRMessage>())
            .AddConverter <JObject, SignalRGroupAction>(input => input.ToObject <SignalRGroupAction>());

            // Trigger binding rule
            var triggerBindingRule = context.AddBindingRule <SignalRTriggerAttribute>();

            triggerBindingRule.AddConverter <InvocationContext, JObject>(JObject.FromObject);
            triggerBindingRule.BindToTrigger <InvocationContext>(new SignalRTriggerBindingProvider(_dispatcher, nameResolver, serviceManagerStore, webhookException));

            // Non-trigger binding rule
            var signalRConnectionInfoAttributeRule = context.AddBindingRule <SignalRConnectionInfoAttribute>();

            signalRConnectionInfoAttributeRule.Bind(inputBindingProvider);

            var securityTokenValidationAttributeRule = context.AddBindingRule <SecurityTokenValidationAttribute>();

            securityTokenValidationAttributeRule.Bind(inputBindingProvider);

            _ = context.AddBindingRule <SignalREndpointsAttribute>()
                .AddConverter <ServiceEndpoint[], JArray>(JArray.FromObject)
                .BindToInput(new SignalREndpointsAsyncConverter());

            var signalRAttributeRule = context.AddBindingRule <SignalRAttribute>();

            signalRAttributeRule.BindToCollector <SignalROpenType>(typeof(SignalRCollectorBuilder <>));

            logger.LogInformation("SignalRService binding initialized");
        }
Ejemplo n.º 4
0
        public void Initialize(ExtensionConfigContext context)
        {
            var rule = context.AddBindingRule <AspNetCoreRunnerAttribute>();

            rule.BindToInput(Factory);

            uri = context.GetWebhookHandler();
        }
            public void Initialize(ExtensionConfigContext context)
            {
                Initializing = true;

                Task.Delay(Delay).GetAwaiter().GetResult();

                Uri url = context.GetWebhookHandler();
            }
Ejemplo n.º 6
0
        /// <summary>
        /// Internal initialization call from the WebJobs host.
        /// </summary>
        /// <param name="context">Extension context provided by WebJobs.</param>
        void IExtensionConfigProvider.Initialize(ExtensionConfigContext context)
        {
            ConfigureLoaderHooks();

            // Functions V1 has it's configuration initialized at startup time (now).
            // For Functions V2 (and for some unit tests) configuration happens earlier in the pipeline.
            if (!this.isOptionsConfigured)
            {
                this.InitializeForFunctionsV1(context);
            }

            // Throw if any of the configured options are invalid
            this.Options.Validate();

            // For 202 support
            if (this.Options.NotificationUrl == null)
            {
#pragma warning disable CS0618 // Type or member is obsolete
                this.Options.NotificationUrl = context.GetWebhookHandler();
#pragma warning restore CS0618 // Type or member is obsolete
            }

            this.TraceConfigurationSettings();

            var bindings = new BindingHelper(this, this.TraceHelper);

            // Note that the order of the rules is important
            var rule = context.AddBindingRule <DurableClientAttribute>()
                       .AddConverter <string, StartOrchestrationArgs>(bindings.StringToStartOrchestrationArgs)
                       .AddConverter <JObject, StartOrchestrationArgs>(bindings.JObjectToStartOrchestrationArgs)
                       .AddConverter <IDurableClient, string>(bindings.DurableOrchestrationClientToString);

            rule.BindToCollector <StartOrchestrationArgs>(bindings.CreateAsyncCollector);
            rule.BindToInput <IDurableOrchestrationClient>(this.GetClient);
            rule.BindToInput <IDurableEntityClient>(this.GetClient);
            rule.BindToInput <IDurableClient>(this.GetClient);

            string storageConnectionString = null;
            var    providerFactory         = this.durabilityProviderFactory as AzureStorageDurabilityProviderFactory;
            if (providerFactory != null)
            {
                storageConnectionString = providerFactory.GetDefaultStorageConnectionString();
            }

            context.AddBindingRule <OrchestrationTriggerAttribute>()
            .BindToTrigger(new OrchestrationTriggerAttributeBindingProvider(this, context, storageConnectionString, this.TraceHelper));

            context.AddBindingRule <ActivityTriggerAttribute>()
            .BindToTrigger(new ActivityTriggerAttributeBindingProvider(this, context, storageConnectionString, this.TraceHelper));

            context.AddBindingRule <EntityTriggerAttribute>()
            .BindToTrigger(new EntityTriggerAttributeBindingProvider(this, context, storageConnectionString, this.TraceHelper));

            this.taskHubWorker = new TaskHubWorker(this.defaultDurabilityProvider, this, this);
            this.taskHubWorker.AddOrchestrationDispatcherMiddleware(this.EntityMiddleware);
            this.taskHubWorker.AddOrchestrationDispatcherMiddleware(this.OrchestrationMiddleware);
        }
Ejemplo n.º 7
0
        public void Initialize(ExtensionConfigContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (string.IsNullOrEmpty(options.ConnectionString))
            {
                options.ConnectionString = nameResolver.Resolve(Constants.AzureSignalRConnectionStringName);
            }

            var serviceTransportTypeStr = nameResolver.Resolve(Constants.ServiceTransportTypeName);

            if (Enum.TryParse <ServiceTransportType>(serviceTransportTypeStr, out var transport))
            {
                options.AzureSignalRServiceTransportType = transport;
            }
            else
            {
                logger.LogWarning($"Unsupported service transport type: {serviceTransportTypeStr}. Use default {options.AzureSignalRServiceTransportType} instead.");
            }

            StaticServiceHubContextStore.ServiceManagerStore = new ServiceManagerStore(options.AzureSignalRServiceTransportType, configuration, loggerFactory);

            var url = context.GetWebhookHandler();

            logger.LogInformation($"Registered SignalR trigger Endpoint = {url?.GetLeftPart(UriPartial.Path)}");

            context.AddConverter <string, JObject>(JObject.FromObject)
            .AddConverter <SignalRConnectionInfo, JObject>(JObject.FromObject)
            .AddConverter <JObject, SignalRMessage>(input => input.ToObject <SignalRMessage>())
            .AddConverter <JObject, SignalRGroupAction>(input => input.ToObject <SignalRGroupAction>());

            // Trigger binding rule
            var triggerBindingRule = context.AddBindingRule <SignalRTriggerAttribute>();

            triggerBindingRule.AddConverter <InvocationContext, JObject>(JObject.FromObject);
            triggerBindingRule.BindToTrigger <InvocationContext>(new SignalRTriggerBindingProvider(_dispatcher, nameResolver, options));

            // Non-trigger binding rule
            var signalRConnectionInfoAttributeRule = context.AddBindingRule <SignalRConnectionInfoAttribute>();

            signalRConnectionInfoAttributeRule.AddValidator(ValidateSignalRConnectionInfoAttributeBinding);
            signalRConnectionInfoAttributeRule.Bind(inputBindingProvider);

            var securityTokenValidationAttributeRule = context.AddBindingRule <SecurityTokenValidationAttribute>();

            securityTokenValidationAttributeRule.Bind(inputBindingProvider);

            var signalRAttributeRule = context.AddBindingRule <SignalRAttribute>();

            signalRAttributeRule.AddValidator(ValidateSignalRAttributeBinding);
            signalRAttributeRule.BindToCollector <SignalROpenType>(typeof(SignalRCollectorBuilder <>), options);

            logger.LogInformation("SignalRService binding initialized");
        }
        /// <summary>
        /// Initialize the O365 binding extension
        /// </summary>
        /// <param name="context">Context containing info relevant to this extension</param>
        public void Initialize(ExtensionConfigContext context)
        {
            _webhookTriggerProvider = new WebhookTriggerBindingProvider();
            _notificationUrl        = context.GetWebhookHandler();

            var graphWebhookConverter = new GraphWebhookSubscriptionConverter(_graphServiceClientManager, _options, _subscriptionStore);

            // Webhooks
            var webhookSubscriptionRule = context.AddBindingRule <GraphWebhookSubscriptionAttribute>();

            webhookSubscriptionRule.BindToInput <Subscription[]>(graphWebhookConverter);
            webhookSubscriptionRule.BindToInput <OpenType[]>(typeof(GenericGraphWebhookSubscriptionConverter <>), _graphServiceClientManager, _options, _subscriptionStore);
            webhookSubscriptionRule.BindToInput <string[]>(graphWebhookConverter);
            webhookSubscriptionRule.BindToInput <JArray>(graphWebhookConverter);
            webhookSubscriptionRule.BindToCollector <string>(CreateCollector);
            context.AddBindingRule <GraphWebhookTriggerAttribute>().BindToTrigger(_webhookTriggerProvider);

            // OneDrive
            var oneDriveService   = new OneDriveService(_graphServiceClientManager);
            var OneDriveRule      = context.AddBindingRule <OneDriveAttribute>();
            var oneDriveConverter = new OneDriveConverter(oneDriveService);

            // OneDrive inputs
            OneDriveRule.BindToInput <byte[]>(oneDriveConverter);
            OneDriveRule.BindToInput <string>(oneDriveConverter);
            OneDriveRule.BindToInput <Stream>(oneDriveConverter);
            OneDriveRule.BindToInput <DriveItem>(oneDriveConverter);
            //OneDriveoutputs
            OneDriveRule.BindToCollector <byte[]>(oneDriveConverter);

            // Excel
            var excelService   = new ExcelService(_graphServiceClientManager);
            var ExcelRule      = context.AddBindingRule <ExcelAttribute>();
            var excelConverter = new ExcelConverter(excelService);

            // Excel Outputs
            ExcelRule.AddConverter <object[][], string>(ExcelService.CreateRows);
            ExcelRule.AddConverter <JObject, string>(excelConverter);
            ExcelRule.AddOpenConverter <OpenType, string>(typeof(ExcelGenericsConverter <>), excelService); // used to append/update arrays of POCOs
            ExcelRule.BindToCollector <string>(excelConverter);
            // Excel Inputs
            ExcelRule.BindToInput <string[][]>(excelConverter);
            ExcelRule.BindToInput <WorkbookTable>(excelConverter);
            ExcelRule.BindToInput <OpenType>(typeof(ExcelGenericsConverter <>), excelService);

            // Outlook
            var outlookService   = new OutlookService(_graphServiceClientManager);
            var OutlookRule      = context.AddBindingRule <OutlookAttribute>();
            var outlookConverter = new OutlookConverter(outlookService);

            // Outlook Outputs
            OutlookRule.AddConverter <JObject, Message>(outlookConverter);
            OutlookRule.AddOpenConverter <OpenType, Message>(typeof(OutlookGenericsConverter <>), outlookService);
            OutlookRule.AddConverter <string, Message>(outlookConverter);
            OutlookRule.BindToCollector <Message>(outlookConverter);
        }
Ejemplo n.º 9
0
        public void Initialize(ExtensionConfigContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (string.IsNullOrEmpty(_options.ConnectionString))
            {
                _options.ConnectionString = _nameResolver.Resolve(Constants.WebPubSubConnectionStringName);
                AddSettings(_options.ConnectionString);
            }

            if (string.IsNullOrEmpty(_options.Hub))
            {
                _options.Hub = _nameResolver.Resolve(Constants.HubNameStringName);
            }

            Exception webhookException = null;

            try
            {
#pragma warning disable CS0618 // Type or member is obsolete
                var url = context.GetWebhookHandler();
#pragma warning restore CS0618 // Type or member is obsolete
                _logger.LogInformation($"Registered Web PubSub negotiate Endpoint = {url?.GetLeftPart(UriPartial.Path)}");
            }
            catch (Exception ex)
            {
                // disable trigger.
                webhookException = ex;
            }

            // register JsonConverters
            RegisterJsonConverter();

            // bindings
            context
            .AddConverter <WebPubSubConnection, JObject>(JObject.FromObject)
            .AddConverter <JObject, WebPubSubOperation>(ConvertToWebPubSubOperation)
            .AddConverter <JArray, WebPubSubOperation[]>(ConvertToWebPubSubOperationArray);

            // Trigger binding
            context.AddBindingRule <WebPubSubTriggerAttribute>()
            .BindToTrigger(new WebPubSubTriggerBindingProvider(_dispatcher, _options, webhookException));

            var webpubsubConnectionAttributeRule = context.AddBindingRule <WebPubSubConnectionAttribute>();
            webpubsubConnectionAttributeRule.AddValidator(ValidateWebPubSubConnectionAttributeBinding);
            webpubsubConnectionAttributeRule.BindToInput(GetClientConnection);

            var webPubSubAttributeRule = context.AddBindingRule <WebPubSubAttribute>();
            webPubSubAttributeRule.AddValidator(ValidateWebPubSubAttributeBinding);
            webPubSubAttributeRule.BindToCollector(CreateCollector);

            _logger.LogInformation("Azure Web PubSub binding initialized");
        }
Ejemplo n.º 10
0
        void IExtensionConfigProvider.Initialize(ExtensionConfigContext context)
        {
            // For 202 support
            if (this.NotificationUrl == null)
            {
#pragma warning disable CS0618 // Type or member is obsolete
                this.NotificationUrl = context.GetWebhookHandler();
#pragma warning restore CS0618 // Type or member is obsolete
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Internal initialization call from the WebJobs host.
        /// </summary>
        /// <param name="context">Extension context provided by WebJobs.</param>
        void IExtensionConfigProvider.Initialize(ExtensionConfigContext context)
        {
            ConfigureLoaderHooks();

            // Functions V1 has it's configuration initialized at startup time (now).
            // For Functions V2 (and for some unit tests) configuration happens earlier in the pipeline.
            if (!this.isOptionsConfigured)
            {
                this.InitializeForFunctionsV1(context);
            }

            if (this.nameResolver.TryResolveWholeString(this.Options.HubName, out string taskHubName))
            {
                // use the resolved task hub name
                this.Options.HubName = taskHubName;
            }

            // Throw if any of the configured options are invalid
            this.Options.Validate();

            // For 202 support
            if (this.Options.NotificationUrl == null)
            {
#pragma warning disable CS0618 // Type or member is obsolete
                this.Options.NotificationUrl = context.GetWebhookHandler();
#pragma warning restore CS0618 // Type or member is obsolete
            }

            this.TraceConfigurationSettings();

            var bindings = new BindingHelper(this, this.TraceHelper);

            // Note that the order of the rules is important
            var rule = context.AddBindingRule <OrchestrationClientAttribute>()
                       .AddConverter <string, StartOrchestrationArgs>(bindings.StringToStartOrchestrationArgs)
                       .AddConverter <JObject, StartOrchestrationArgs>(bindings.JObjectToStartOrchestrationArgs)
                       .AddConverter <DurableOrchestrationClient, string>(bindings.DurableOrchestrationClientToString);

            rule.BindToCollector <StartOrchestrationArgs>(bindings.CreateAsyncCollector);
            rule.BindToInput <DurableOrchestrationClient>(this.GetClient);

            context.AddBindingRule <OrchestrationTriggerAttribute>()
            .BindToTrigger(new OrchestrationTriggerAttributeBindingProvider(this, context, this.TraceHelper));

            context.AddBindingRule <ActivityTriggerAttribute>()
            .BindToTrigger(new ActivityTriggerAttributeBindingProvider(this, context, this.TraceHelper));

            this.orchestrationServiceSettings = this.GetOrchestrationServiceSettings();
            this.orchestrationService         = new AzureStorageOrchestrationService(this.orchestrationServiceSettings);
            this.taskHubWorker = new TaskHubWorker(this.orchestrationService, this, this);
            this.taskHubWorker.AddOrchestrationDispatcherMiddleware(this.OrchestrationMiddleware);
        }
        public void Initialize(ExtensionConfigContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            _logger = _loggerFactory.CreateLogger <EventGridExtensionConfigProvider>();

#pragma warning disable 618
            Uri url = context.GetWebhookHandler();
#pragma warning restore 618
            _logger.LogInformation($"registered EventGrid Endpoint = {url?.GetLeftPart(UriPartial.Path)}");

            // Register our extension binding providers
            // use converterManager as a hashTable
            // also take benefit of identity converter
            context
            .AddBindingRule <EventGridTriggerAttribute>()    // following converters are for EventGridTriggerAttribute only
            .AddConverter <JToken, string>(jtoken => jtoken.ToString(Formatting.Indented))
            .AddConverter <JToken, string[]>(jarray => jarray.Select(ar => ar.ToString(Formatting.Indented)).ToArray())
            .AddConverter <JToken, DirectInvokeString>(jtoken => new DirectInvokeString(null))
            .AddConverter <JToken, EventGridEvent>(jobject => EventGridEvent.Parse(new BinaryData(jobject.ToString())))    // surface the type to function runtime
            .AddConverter <JToken, EventGridEvent[]>(jobject => EventGridEvent.ParseMany(new BinaryData(jobject.ToString())))
            .AddConverter <JToken, CloudEvent>(jobject => CloudEvent.Parse(new BinaryData(jobject.ToString())))
            .AddConverter <JToken, CloudEvent[]>(jobject => CloudEvent.ParseMany(new BinaryData(jobject.ToString())))
            .AddConverter <JToken, BinaryData>(jobject => new BinaryData(jobject.ToString()))
            .AddConverter <JToken, BinaryData[]>(jobject => jobject.Select(obj => new BinaryData(obj.ToString())).ToArray())
            .AddOpenConverter <JToken, OpenType.Poco>(typeof(JTokenToPocoConverter <>))
            .AddOpenConverter <JToken, OpenType.Poco[]>(typeof(JTokenToPocoConverter <>))
            .BindToTrigger <JToken>(new EventGridTriggerAttributeBindingProvider(this));

            // Register the output binding
            var rule = context.AddBindingRule <EventGridAttribute>();
            rule.BindToCollector(_converter);
            rule.AddValidator((a, t) =>
            {
                // if app setting is missing, it will be caught by runtime
                // this logic tries to validate the practicality of attribute properties
                if (string.IsNullOrWhiteSpace(a.TopicKeySetting))
                {
                    throw new InvalidOperationException($"The '{nameof(EventGridAttribute.TopicKeySetting)}' property must be the name of an application setting containing the Topic Key");
                }

                if (!Uri.IsWellFormedUriString(a.TopicEndpointUri, UriKind.Absolute))
                {
                    throw new InvalidOperationException($"The '{nameof(EventGridAttribute.TopicEndpointUri)}' property must be a valid absolute Uri");
                }
            });
        }
        /// <summary>
        /// Internal initialization call from the WebJobs host.
        /// </summary>
        /// <param name="context">Extension context provided by WebJobs.</param>
        void IExtensionConfigProvider.Initialize(ExtensionConfigContext context)
        {
            ConfigureLoaderHooks();

            context.ApplyConfig(this, "DurableTask");

            // Register the trigger bindings
            JobHostConfiguration hostConfig = context.Config;
            ILogger logger = context.Config.LoggerFactory.CreateLogger(LoggerCategoryName);

            this.traceHelper    = new EndToEndTraceHelper(hostConfig, logger, this.LogReplayEvents);
            this.httpApiHandler = new HttpApiHandler(this, logger);

            this.lifeCycleNotificationHelper = new LifeCycleNotificationHelper(this, context);

            // Register the non-trigger bindings, which have a different model.
            var bindings = new BindingHelper(this, this.traceHelper);

            // For 202 support
            if (this.NotificationUrl == null)
            {
#pragma warning disable CS0618 // Type or member is obsolete
                this.NotificationUrl = context.GetWebhookHandler();
#pragma warning restore CS0618 // Type or member is obsolete
            }

            // Note that the order of the rules is important
            var rule = context.AddBindingRule <OrchestrationClientAttribute>()
                       .AddConverter <string, StartOrchestrationArgs>(bindings.StringToStartOrchestrationArgs)
                       .AddConverter <JObject, StartOrchestrationArgs>(bindings.JObjectToStartOrchestrationArgs);

            rule.BindToCollector <StartOrchestrationArgs>(bindings.CreateAsyncCollector);
            rule.BindToInput <DurableOrchestrationClient>(this.GetClient);

            context.AddBindingRule <OrchestrationTriggerAttribute>()
            .BindToTrigger(new OrchestrationTriggerAttributeBindingProvider(this, context, this.traceHelper));

            context.AddBindingRule <ActivityTriggerAttribute>()
            .BindToTrigger(new ActivityTriggerAttributeBindingProvider(this, context, this.traceHelper));

            AzureStorageOrchestrationServiceSettings settings = this.GetOrchestrationServiceSettings();
            this.orchestrationService = new AzureStorageOrchestrationService(settings);
            this.taskHubWorker        = new TaskHubWorker(this.orchestrationService, this, this);
            this.taskHubWorker.AddOrchestrationDispatcherMiddleware(this.OrchestrationMiddleware);

            context.Config.AddService <IOrchestrationService>(this.orchestrationService);
        }
Ejemplo n.º 14
0
        public void Initialize(ExtensionConfigContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            _logger = _loggerFactory.CreateLogger(LogCategories.CreateTriggerCategory("EventGrid"));

            Uri url = context.GetWebhookHandler();

            _logger.LogInformation($"registered EventGrid Endpoint = {url?.GetLeftPart(UriPartial.Path)}");

            // Register our extension binding providers
            // use converterManager as a hashTable
            // also take benefit of identity converter
            context
            .AddBindingRule <EventGridTriggerAttribute>()                                             // following converters are for EventGridTriggerAttribute only
            .AddConverter <JObject, string>((jobject) => jobject.ToString(Formatting.Indented))
            .AddConverter <string, JObject>((str) => JObject.Parse(str))                              // used for direct invocation
            .AddConverter <JObject, EventGridEvent>((jobject) => jobject.ToObject <EventGridEvent>()) // surface the type to function runtime
            .AddOpenConverter <JObject, OpenType.Poco>(typeof(JObjectToPocoConverter <>))
            .BindToTrigger <JObject>(new EventGridTriggerAttributeBindingProvider(this));

            // Register the output binding
            var rule = context
                       .AddBindingRule <EventGridAttribute>()
                       .AddConverter <string, EventGridEvent>((str) => JsonConvert.DeserializeObject <EventGridEvent>(str))
                       .AddConverter <JObject, EventGridEvent>((jobject) => jobject.ToObject <EventGridEvent>());

            rule.BindToCollector(_converter);
            rule.AddValidator((a, t) =>
            {
                // if app setting is missing, it will be caught by runtime
                // this logic tries to validate the practicality of attribute properties
                if (string.IsNullOrWhiteSpace(a.TopicKeySetting))
                {
                    throw new InvalidOperationException($"The '{nameof(EventGridAttribute.TopicKeySetting)}' property must be the name of an application setting containing the Topic Key");
                }

                if (!Uri.IsWellFormedUriString(a.TopicEndpointUri, UriKind.Absolute))
                {
                    throw new InvalidOperationException($"The '{nameof(EventGridAttribute.TopicEndpointUri)}' property must be a valid absolute Uri");
                }
            });
        }
        public void Initialize(ExtensionConfigContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            else if (context.Trace == null)
            {
                throw new ArgumentNullException("context.Trace");
            }
            _tracer = context.Trace;

            Uri url = context.GetWebhookHandler();

            // Register our extension binding providers
            context.Config.RegisterBindingExtension(new EventGridTriggerAttributeBindingProvider(this));
        }
Ejemplo n.º 16
0
        public void Initialize(ExtensionConfigContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            else if (context.Trace == null)
            {
                throw new ArgumentNullException("context.Trace");
            }
            _tracer = context.Trace;

            Uri url = context.GetWebhookHandler();

            _tracer.Trace(new TraceEvent(System.Diagnostics.TraceLevel.Info, $"registered EventGrid Endpoint = {url}"));

            // Register our extension binding providers
            context.Config.RegisterBindingExtension(new EventGridTriggerAttributeBindingProvider(this));
        }
        /// <summary>
        /// Initialize the O365 binding extension
        /// </summary>
        /// <param name="context">Context containing info relevant to this extension</param>
        public void Initialize(ExtensionConfigContext context)
        {
            var config = context.Config;

            _appSettings = config.NameResolver;

            // Set up logging
            _log = context.Trace;

            ConfigureServiceManager(context);

            // Infer a blank Notification URL from the appsettings.
            string appSettingBYOBTokenMap = _appSettings.Resolve(O365Constants.AppSettingBYOBTokenMap);
            var    subscriptionStore      = _subscriptionStore ?? new WebhookSubscriptionStore(appSettingBYOBTokenMap);
            var    webhookTriggerProvider = new WebhookTriggerBindingProvider();

            _webhookConfig = new GraphWebhookConfig(context.GetWebhookHandler(), subscriptionStore, webhookTriggerProvider);

            var graphWebhookConverter = new GraphWebhookSubscriptionConverter(_serviceManager, _webhookConfig);

            // Webhooks
            var webhookSubscriptionRule = context.AddBindingRule <GraphWebhookSubscriptionAttribute>();

            webhookSubscriptionRule.BindToInput <Subscription[]>(graphWebhookConverter);
            webhookSubscriptionRule.BindToInput <OpenType[]>(typeof(GenericGraphWebhookSubscriptionConverter <>), _serviceManager, _webhookConfig);
            webhookSubscriptionRule.BindToInput <string[]>(graphWebhookConverter);
            webhookSubscriptionRule.BindToInput <JArray>(graphWebhookConverter);
            webhookSubscriptionRule.BindToCollector <string>(CreateCollector);

            context.AddBindingRule <GraphWebhookTriggerAttribute>().BindToTrigger(webhookTriggerProvider);

            // OneDrive
            var OneDriveRule      = context.AddBindingRule <OneDriveAttribute>();
            var oneDriveConverter = new OneDriveConverter(_serviceManager);

            // OneDrive inputs
            OneDriveRule.BindToInput <byte[]>(oneDriveConverter);
            OneDriveRule.BindToInput <string>(oneDriveConverter);
            OneDriveRule.BindToInput <Stream>(oneDriveConverter);
            OneDriveRule.BindToInput <DriveItem>(oneDriveConverter);

            OneDriveRule.BindToCollector <byte[]>(CreateCollector);

            // Excel
            var ExcelRule = context.AddBindingRule <ExcelAttribute>();

            var excelConverter = new ExcelConverter(_serviceManager);

            // Excel Outputs
            ExcelRule.AddConverter <object[][], JObject>(ExcelService.CreateRows);
            ExcelRule.AddConverter <List <OpenType>, JObject>(typeof(GenericExcelRowConverter <>)); // used to append/update lists of POCOs
            ExcelRule.AddConverter <OpenType, JObject>(typeof(GenericExcelRowConverter <>));        // used to append/update arrays of POCOs
            ExcelRule.BindToCollector <JObject>(excelConverter.CreateCollector);
            ExcelRule.BindToCollector <JObject>(typeof(POCOExcelRowConverter <>));

            // Excel Inputs
            ExcelRule.BindToInput <string[][]>(excelConverter);
            ExcelRule.BindToInput <WorkbookTable>(excelConverter);
            ExcelRule.BindToInput <List <OpenType> >(typeof(POCOExcelRowConverter <>), _serviceManager);
            ExcelRule.BindToInput <OpenType>(typeof(POCOExcelRowConverter <>), _serviceManager);

            // Outlook
            var OutlookRule = context.AddBindingRule <OutlookAttribute>();

            // Outlook Outputs
            OutlookRule.AddConverter <JObject, Message>(OutlookService.CreateMessage);
            OutlookRule.AddConverter <string, Message>(OutlookService.CreateMessage);
            OutlookRule.BindToCollector <Message>(CreateCollector);
        }