Skip to content
Branch: master
Go to file
Code

Latest commit

willarmiros committed 3391ce9 Jun 22, 2020
Merge pull request #5 from aws-samples/dependabot/nuget/DotNETCore/Mi…
…crosoft.AspNetCore.All-2.0.9

Bump Microsoft.AspNetCore.All from 2.0.3 to 2.0.9 in /DotNETCore

Files

Permalink
Failed to load latest commit information.

README.md

aws-xray-dotnet-webapp

An ASP.NET and ASP.NET Core application that has been instrumented for AWS X-Ray.

These applications are written to be deployed with Elastic Beanstalk or run locally.

How to Run The App

Elastic beanstalk

Deploy
  1. Attach an IAM role to your EC2 instance with the policy
  2. Deploy the application to Elastic Beanstalk. Steps
  3. Configure Sampling Rules in the AWS X-Ray Console
EbExtensions

The App uses .ebextensions to setup AWS resources and configuration, which includes:

  1. Create a DynamoDB table with name SampleProduct
  2. Set an application config DDB_TABLE_NAME with the create DynamoDB table name
  3. Install AWS X-Ray daemon as a Windows service

Locally

  1. AWS Credentials on the local box should have the policy
  2. Create a DynamoDB table with name SampleProduct in the desired region. The partion key for the table should be Id and of type Number.
  3. Install AWS X-Ray daemon as a Windows service
  4. Comment DDB client creation for .NET and .NET Core, which is used for Elasticbeanstalk and uncomment line for .NET and .NET Core
  5. Make sure, the region is same for DDB table on the AWS console and DDB client in the code for .NET and .NETCore
  6. Configure Sampling Rules in the AWS X-Ray Console.
  7. The X-Ray daemon running locally should be configured in the same region as that of sampling rules through X-Ray console

URL for the App

Access the application : <Default_URL>/index.html.

Policy

 {
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "sns:Publish",
                "xray:PutTraceSegments",
                "xray:PutTelemetryRecords",
                "xray:GetSamplingRules",
                "xray:GetSamplingTargets",
                "xray:GetSamplingStatisticSummaries",
                "dynamodb:PutItem",
                "dynamodb:GetItem",
                "dynamodb:DescribeTable"
            ],
            "Resource": [
                "*"
            ],
            "Effect": "Allow"
        }
    ]
}

Enable SQL query (optional)

  1. By default, SQL query is disabled.
  2. Create a RDS SQL Server DB instance. Steps
  3. Construct the connection string for SQL Server "Data Source=(RDS endpoint),(port number);User ID=(your user name);Password=(your password);"
  4. Fill it into web.config key "RDS_CONNECTION_STRING" for .NET and fill the string for .NETCore
  5. Uncomment call to QuerySql() for .NET and .NETCore

Documentation

  1. Code repository for AWS X-Ray SDK for .NET/Core
  2. AWS Documentation for using X-Ray SDK for .NET

FAQ

  1. What to do if I get an "Error: Internal Server Error"?
  • You can use AWS X-Ray to debug this. Go to AWS X-Ray console and find the failed trace, and look for Exception. Probably because you EC2 instance don't have the enough permission to access DynamoDB or RDS DB instance.

About

An ASP.NET Web API application that has been instrumented for AWS X-Ray

Resources

License

Releases

No releases published
You can’t perform that action at this time.