reference-architectures | community project | Serverless library
kandi X-RAY | reference-architectures Summary
kandi X-RAY | reference-architectures Summary
This project is intended to capture, share, explore, and debate the patterns and practices being used in serverless production applications today.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of reference-architectures
reference-architectures Key Features
reference-architectures Examples and Code Snippets
Community Discussions
Trending Discussions on reference-architectures
QUESTION
The new support for Event Hub Riders in 7.0 plus the existing InMemoryRepository
backing for Sagas looks like it could provide a straightforward means of creating aggregate states based on a stream of correlated messages, e.g. across all sensors in a Building). In this scenario, the Building's Identifier would be used as the CorrelationId of the Messages, the Saga, and as the PartitionKey of the EventData messages sent to the Event Hub, ensuring the same consuming service instance receives all messages for that device at a given time. Given the way Event Hub's rebalancing works, it can be assumed that at some point while this service is running, the service instance managing messages for a Partition will shift to a new host, which will start reading messages sent by the sensors in the building. At that moment:
- The new host does not know anything about the old host's processing. It just knows that it is now receiving messages for the Event Hub partition that includes that Building's messages.
- The devices sending the messages do not know anything about the transition in state aggregation responsibility "downstream of them" - they are still happily reporting new measurements as always.
The challenge this creates is: on the new service instance, we need a new Saga to be created to take over for the previous Saga, but the only thing that knows no Saga lives for a given entity is MassTransit: nothing on the new instance knows a sensor reading from Building A is the first one from Building A since this service instance took over tracking the aggregate Building A state. We thought this could be handled by marking the same Message (DataCollected
) with both InitiatedBy
and Orchestrates
:
ANSWER
Answered 2020-Nov-03 at 20:09As per Chris Patterson's comments on the question above, this is achievable with the state machine syntax:
QUESTION
I have an old web application which is using ASP.net with the build in cookie based authentication which has the standard ASP.net SQL tables for storing the users credentials.
This is currently running as an Azure web app, but I was toying with the idea of trying to go serverless as per this example creating a ReactJs SPA hosting on blob storage to try and keep costs down and also improve performance without breaking the bank.
https://docs.microsoft.com/en-us/azure/architecture/reference-architectures/serverless/web-app
I was wondering if it is possible to port over the existing ASP.net authentication to Azure functions, to instead return a JWT (JSON Web Token) which could be passed back in the headers to handle authenticated requests.
When I have tried this in the past I have failed misserably, so I was wondering if anyone knows if it is possible?
I've seen this article, which seems to talk about Azure functions doing authentication, but with Azure AD, which I don't think is right for what I need.
...ANSWER
Answered 2020-Jan-23 at 16:23The answer is kind of. What I mean by this is that you can use your existing database and many of the same libraries, but you can't port over the code configuration. The default authentication for Functions is either 1) The default API tokens or 2) one of the EasyAuth providers baked into App Services which is in the guide you linked. Currently, any other solution you'll need to setup yourself.
Assuming you go with the JWT option, you'll need to turn off all of the built-in authentication for Functions. This includes setting your HttpRequest functions to AuthorizationLevel.Anonymous
.
At a basic level You'll need to create two things. A function to issue tokens, and either a DI service or a custom input binding to check them.
Issuing tokens
The Functions 2.x+ runtime is on .NET Core so I'm gong to borrow some code from this blog post that describes using JWTs with Web API. It uses System.IdentityModel.Tokens.Jwt
to generate a token, which we could then return from the Function.
QUESTION
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: "Template to set up Kinesis stream, Lambda functions, S3 bucket, DynamoDB table and related IAM roles for AWS Lambda Real-time Stream Processing Reference Architecture. PLEASE NOTE: The CloudFormation Stack Name must be all lowercase as it is used as part of the S3 bucket name. Otherwise the stack creation will fail."
Parameters:
LambdaS3Bucket:
Type: String
Default: awslambda-reference-architectures
Description: Name of S3 bucket where Lambda function packages are stored.
LambdaDDBEventProcessorS3Key:
Type : String
Default : stream-processing/ddb_eventprocessor.zip
Description : Name of S3 key for Zip with Stream Processing DynamoDB Event Processor Lambda function package.
LambdaDDBEventProcessorHandler:
Type : String
Default : ddb_eventprocessor.handler
Description : Name of handler for Stream Processing DynamoDB Event Processor Lambda function.
Resources:
EventStream:
Type: 'AWS::Kinesis::Stream'
Properties:
ShardCount: 1
DDBEventProcessor:
Type: 'AWS::Serverless::Function'
Properties:
Description: Stream Processing DDB Event Processor
Handler: !Ref LambdaDDBEventProcessorHandler
MemorySize: 128
Role: !GetAtt
- EventProcessorExecutionRole
- Arn
Timeout: 10
Runtime: nodejs6.10
CodeUri:
Bucket: !Ref LambdaS3Bucket
Key: !Ref LambdaDDBEventProcessorS3Key
Events:
Stream:
Type: Kinesis
Properties:
Stream: !GetAtt EventStream.Arn
StartingPosition: TRIM_HORIZON
BatchSize: 25
EventDataTable:
Type: 'AWS::DynamoDB::Table'
Properties:
AttributeDefinitions:
- AttributeName: Username
AttributeType: S
- AttributeName: Id
AttributeType: S
KeySchema:
- AttributeName: Username
KeyType: HASH
- AttributeName: Id
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: '1'
WriteCapacityUnits: '1'
TableName: !Join
- ''
- - !Ref 'AWS::StackName'
- '-EventData'
EventProcessorExecutionRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- 'sts:AssumeRole'
Path: /
Policies:
- PolicyName: EventProcessorExecutionPolicy
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- 'logs:*'
Resource: 'arn:aws:logs:*:*:*'
- Effect: Allow
Action:
- 'dynamodb:BatchWriteItem'
Resource: !Join
- ''
- - 'arn:aws:dynamodb:'
- !Ref 'AWS::Region'
- ':'
- !Ref 'AWS::AccountId'
- ':table/'
- !Ref 'AWS::StackName'
- '-EventData'
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/service-role/AWSLambdaKinesisExecutionRole'
streamprocessingclient:
Type: 'AWS::IAM::User'
ClientPolicy:
Type: 'AWS::IAM::Policy'
Properties:
PolicyName: StreamProcessingClientPolicy
PolicyDocument:
Statement:
- Effect: Allow
Action:
- 'kinesis:Put*'
Resource: !Join
- ''
- - 'arn:aws:kinesis:'
- !Ref 'AWS::Region'
- ':'
- !Ref 'AWS::AccountId'
- ':stream/'
- !Ref EventStream
Users:
- !Ref streamprocessingclient
ClientKeys:
Type: 'AWS::IAM::AccessKey'
Properties:
UserName: !Ref streamprocessingclient
Outputs:
AccessKeyId:
Value: !Ref ClientKeys
Description: AWS Access Key Id of stream processing client user
SecretAccessKey:
Value: !GetAtt
- ClientKeys
- SecretAccessKey
Description: AWS Secret Key of stream processing client user
KinesisStream:
Value: !Ref EventStream
Description: The Kinesis stream used for ingestion.
Region:
Value: !Ref 'AWS::Region'
Description: The region this template was launched in.
...ANSWER
Answered 2019-Oct-09 at 19:04cfn-lint warns:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install reference-architectures
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page