Beispiel #1
0
 public async Task <IEnumerable <ToDoMessage> > Run(
     FunContext context,
     IReadOnlyCollection <ToDoItem> input,
     CancellationToken cancellationToken)
 => input.Select(i => new ToDoMessage {
     id = i.id, creationTime = i.creationTime
 });
Beispiel #2
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("ConsoleApp1 is starting");

            var config = new ConfigurationBuilder()
                         .SetBasePath(Directory.GetCurrentDirectory())
                         .AddJsonFile("appsettings.json", optional: false)
                         .AddEnvironmentVariables()
                         .Build();

            Console.WriteLine("Creating CosmosClient");

            // Cosmos
            var cosmos = new CosmosClient(config["Cosmos_ConnectionString"]);

            // Fun
            Console.WriteLine("Binding Fun");
            var controller = new FunController();
            var context    = new FunContext(controller);

            var fun = new CosmosChangeFeedFunBinding(context, cosmos, config);
            await fun.Bind();

            Console.WriteLine("Ready. Press any key to stop.");

            while (!Console.KeyAvailable)
            {
                await Task.Delay(1);
            }

            Console.WriteLine("Unbinding Fun.");
            await fun.UnBind();
        }
Beispiel #3
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("ConsoleApp1 is starting");

            var config = new ConfigurationBuilder()
                         .SetBasePath(Directory.GetCurrentDirectory())
                         .AddJsonFile("appsettings.json", optional: false)
                         .AddEnvironmentVariables()
                         .Build();

            Console.WriteLine("Creating Storage Client");

            // Storage
            var storageClient = new BlobContainerClient(config["Blob_ConnectionString"], config["Blob_Container"]);

            Console.WriteLine("Creating EventProcessorClient");

            // Event Hubs
            var processor = new EventProcessorClient
                            (
                storageClient,
                "$Default",
                config["EventHub_ConnectionString"],
                config["EventHub_HubName"]
                            );

            Console.WriteLine("Creating CosmosClient");

            // Cosmos
            var cosmos          = new CosmosClient(config["Cosmos_ConnectionString"]);
            var cosmosContainer = cosmos.GetContainer(config["Cosmos_DatabaseName"], config["Cosmos_ContainerName"]);

            // Fun
            Console.WriteLine("Binding Fun");
            var controller = new FunController();
            var context    = new FunContext(controller);

            var fun = new SaveEventFun(processor, cosmosContainer, context);
            await fun.Bind();

            Console.WriteLine("Ready. Press any key to stop.");

            while (!Console.KeyAvailable)
            {
                await Task.Delay(1);
            }

            Console.WriteLine("Unbinding Fun.");
            await fun.UnBind();
        }
Beispiel #4
0
 public override Task <MyDocument> Run(FunContext context, MyEvent input, CancellationToken cancellationToken)
 {
     try
     {
         Console.WriteLine("Run");
         return(Task.FromResult(
                    new MyDocument {
             Id = Guid.NewGuid().ToString("N"),
             MyProperty = input.MyProperty
         }));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         //context.Logger.LogError(ex);
         context.PostHealth(FunHealth.Failure(ex));
         throw;
     }
 }
 public IssuesController(FunContext ctx)
 {
     _ctx = ctx;
 }
 public FunAPIController(FunContext context)
 {
     _context = context;
 }
Beispiel #7
0
 public CosmosChangeFeedFunBinding(FunContext context, CosmosClient cosmos, IConfiguration config) : base(context)
 {
     _cosmos = cosmos;
     _config = config;
 }
 public RootController(FunContext ctx)
 {
     _ctx = ctx;
 }
Beispiel #9
0
 public SaveEventFun(EventProcessorClient processor, Container container, FunContext context) : base(processor, container, context)
 {
 }
 public abstract Task <TOutput> Run(FunContext context, TInput input, CancellationToken cancellationToken);
 public EventHubCosmosFunBinding(EventProcessorClient processor, Container container, FunContext context) : base(context)
 {
     EventProcessorClient = processor;
     _container           = container;
 }
Beispiel #12
0
 public ArtistsController(FunContext funContext)
 {
     _funContext = funContext;
 }
 public CourseController(FunContext ctx)
 {
     _ctx = ctx;
 }
Beispiel #14
0
 public override Task <MyModel> Run(FunContext context, MyModel input, CancellationToken cancellationToken)
 {
     return(Task.FromResult(input));
 }
 public RootController(IMailService svc, FunContext ctx)
 {
     _svc = svc;
     _ctx = ctx;
 }
Beispiel #16
0
 public HelloFun(FunContext context) : base(context)
 {
 }
Beispiel #17
0
 public HttpFunBinding(FunContext context) : base(context)
 {
 }