Download presentation
Presentation is loading. Please wait.
Published byHeather Pitts Modified over 9 years ago
1
Part 04 – Preparing to Deploy to the Cloud Entity Framework and MVC Series Tom Perkins NTPCUG
2
Environment Change … CURRENT ENVIRONMENT LOCAL MACHINE CONTOSO APP IIS SQL Server Express LocalDB database Web Hosting Provider TARGET ENVIRONMENT CLOUD Database Server Deploy
3
This tutorial … Two EF 6 Features Connection Resiliency – Automatic retries for transient errors – transient – lasting only for a short time; impermanent Command Interception – Intercept all SQL queries sent to DB to log or change them
4
Reasons for transient errors App and database may not be in the same datacenter Load balancers may interfere Having many other users may effect responsiveness Service Level Agreement – how frequently you can access the database – throws exceptions (throttling) Contoso App Windows Azure SQL Database Windows Azure SQL Database
5
Connection Problems May resolve themselves in a short period of time A short wait may lead to a successful operation Connection Resiliency – EF6 feature – Automatically tries transient errors again – Invisible to customer
6
Connection Resiliency Feature Must be configured for particular database service (EF6 defaults to Windows Azure) Must identify ‘transient’ errors – don’t retry program bugs Wait only an appropriate amount of time before retrying – users are waiting … Try only an appropriate number of times
7
Contoso App – Enable Connection Resiliency Set SQL database “execution strategy” – EF term for ‘retry policy’ Follow the steps outlined in Part 04 Exercise 1 – Set Retry Policy (Handout)
8
Command Interception How to test retry policy? Plan: – Intercept SQL queries EF sends to SQL – Replace SQL server response with a transient error exception type EF6’s Interception Feature – Use for logging – Use for simulation of transient errors
9
Exercise 2 – Logging Interface and Class Perform the steps in Exercise 2 – Create Logging Interface and Implementation Class
10
Interceptor Classes Called each time EF sends a query to the database Classes derive from DbCommandInterceptor class – Override methods that are called when query is about to be executed – Examine or change the query *** OR *** – Return something to EF without sending it to SQL 2 classes – SchoolInterceptorLogging.cs – does logging – SchoolInterceptorTransientErrors.cs – “Throw” in Search string produces dummy transient errors
11
Interceptor Classes Follow Exercise 3 – Interceptor Classes
12
Testing – Exercise 4 To test both logging and transient error handling, follow the steps in Exercise 4 Note that not all the output from the logging and exception has been copied – you should be able to see this on your display as you work through the exercise.
13
Part 04 – What We Did Enabled Connection Resiliency Log SQL commands from EF to database Next: – Use CodeFirst Migrations to deploy to Azure
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.