PaaS - Exploration and Deployment of
WCF C# web services with AWS
Elastic Beanstalk
Objective: Get practical experience in C# WCF Web services development and deployment on
Cloud PaaS with AWS Elastic Beanstalk as well as in creating and running web service clients.
Tasks:
1. Explore a C# WCF Web Service
2. Test a Web Service using SoapUI tool
3. Explore a WCF Web Service C# client
4. Deploy a C# WCF Web Service on AWS Elastic Beanstalk PaaS service
Lab environment:
● Visual Studio IDE with the following workloads:
o ASP.NET and web development
o Azure development
o AWS Toolkit for Visual Studio (https://aws.amazon.com/visualstudio/)
● SoapUI tool
Contents
Step 0: Downloading the project 3
Step 1: Running Visual Studio 2007 3
Step 2: Exploring C# WCF Web Service 4
Exploring the Service1.svc.cs 4
Exploring the IService1.cs 5
Launching and testing the WCF Web Service 5
Step 3: Exploring and executing the WCF Web Service Client 8
Step 4: Launching a Web Service on AWS Elastic Beanstalk PaaS 9
Launching a Web Service on the AWS Elastic Beanstalk PaaS 9
Test the WCF Web Service deployed at AWS Elastic Beanstalk 15
Step 4: Deleting AWS Elastic Beanstalk resources after use 17
Step 0: Downloading the Project
From the VLE download the repos.zip file and save it to C:\Users\c1234567\source\ folder on
the University (bottom) PC, where c1234567 – is your user id.
Extract All...
Make sure you have WcfClientCalc and WcfServiceCalc folders exactly in C:\Users\c1234567\
source\repos location:
Step 1: Running Visual Studio
Run the Visual Studio on the University’s PC and sign in with your uni email:
Open the WcfServiceCalc project in the solution Explorer panel (open C:\Users\c1234567\
source\repos) and open two .cs source files: Service1.svc.cs and IService1.cs.
Agree to update the project to .NET Framework 4.8 if prompted:
When you first run Visual Studio you might be prompted to configure AWS Plugin (if not. go to
Extensions->AWS Toolkit->Getting started). There you need to configure your access to AWS
Explorer by setting IAM User Role and providing your Access key and a Secret key created
during the first tutorial. As a profile name use ‘default’.
.
Go to the Solution explorer and open the WcfServiceCalc project.
Step 2: Exploring C# WCF Web Service
Windows Communication Foundation (WCF) is a framework for building service-oriented
applications. Using WCF, you can send data as asynchronous messages from one service
endpoint to another. A service endpoint can be part of a continuously available service hosted
by IIS (Internet Information Server), or it can be a service hosted in an application. An endpoint
can be a client of a service that requests data from a service endpoint. The messages can be as
simple as a single character or word sent as XML, or as complex as a stream of binary data.
Exploring the Service1.svc.cs
The C# class Service1 implements IService1 interface. It implements four methods: Add,
Subtract, Multiply and Divide. Each method accepts two operands and returns the result of a
corresponding arithmetic operation.
Exploring the IService1.cs
IService.cs describes a Web Service interface by specifying service’s operations and their input
and output parameters.
Launching and testing the WCF Web Service
a. In order to launch WCF Web Service for testing this service, please select Service1.svc.cs
at the Solution Explorer and start debugging.
Visual Studio includes IIS Express, a lightweight, self-contained version of IIS optimized for
developers. It makes it easy to develop and test web project.
b. After Visual the web service starts, the WCF Test Client launches automatically. It will
detect Web Service interface description (WSDL) and generate stubs for all web service
operations. You can change values of the input parameters, invoke the web service and
check the result returned in service’s response.
WCF Test Client (WcfTestClient.exe) is a GUI tool (it is a part of Visual Studio) that allows
you to input parameters of arbitrary types, submit that input to the service, and view the
response the service sends back. It provides a seamless service testing experience when
combined with WCF Service Auto Host.
c. You can also see the raw XML request and response sent to and received from the web service.
d. Run a web browser and check WSDL description of the web service at:
http://localhost:52788/Service1.svc?wsdl (the port number in your case can be different from
52788 as in the above example; please, notice the right port number from the WCF Test Client
window as shown below:
e. You can also test the web service using SoapUI tool. Run the SoapUI on your PC and create a
new SOAP Project. Provide the URL to the wsdl file, e.g. http://localhost:52788/Service1.svc?
wsdl:
f. Select one of the methods, e.g. Add; set values of n1 and n2 operands in the request template
and invoke the service (press on the green triangle button). Notice the response (switch
between Xml and Raw). Experiment with different service’s methods and values.
Step 3: Exploring and executing the WCF Web Service
Client
a. Open a new copy of Visual Studio (make sure the first Visual Studio still executes the
WcfServerCalc project).
b. Open the WcfClientCalc project in the solution Explorer panel (open from C:\Users\
tennin\source\repos) and open the Program.cs file. The WcfClientCalc is a desktop
application which invokes different operations of the WcfServerCalc service.
c. Explore the client’s program code in Program.cs and notice the way a web service is
invoked
d. Check the app.config which specifies the target Web Service. Notice the URL address of
the service. Change it if needed.
e. Execute (run) the client.
a. Close the WcfClientCalc and stop debugging of the WcfServerCalc.
Step 4: Launching a Web Service on AWS Elastic Beanstalk
PaaS
AWS Elastic Beanstalk is an easy-to-use PaaS service for deploying and scaling web
applications and services developed with Java, .NET, PHP, Node.js, Python, Ruby, Go, and
Docker on familiar servers such as Apache, Nginx, Passenger, and IIS.
You can simply upload your code and Elastic Beanstalk automatically handles the deployment,
from capacity provisioning, load balancing, auto-scaling to application health monitoring. At
the same time, you retain full control over the AWS resources powering your application and
can access the underlying resources at any time.
You need to pay for the AWS resources needed to store and run your applications. Usually
your code runs on one or several dedicated VMs.
Launching a Web Service on the AWS Elastic Beanstalk PaaS
1. Notice the static html page default.html that was added into the WcfServerCalc project.
AWS Load Balancer periodically (every 10 seconds) sends requests to the registered instances to
test their status by sending HTTP GET requests. These tests are called health checks. An instance
is considered healthy if it returns a 200 response code within the health check interval. By
default, the load balancer is configured to open a TCP connection on port 80. If the instance
acknowledges the connection, it is considered healthy. Thus, you need to have some web page
in the root of your Web service to pass the health check when the instance is deployed. Later
on, you will be able to override this setting by specifying another path, e.g. a URL to the WSDL
description of your web service.
2. Configure the AWS default profile on Visual Studio to get access to your AWS account.
Note: Skip this stage if you have already created Access Key during the first tutorial - simply open the
credentials file with aws_access_key and aws_secret_access_key that you saved before.
a. Log in to your AWS account https://aws.amazon.com/ and select/search for IAM (Identity
and Access Management) centre:
Click on ‘Manage access keys’ and create a New Access Key
You will be provided a pair of Access Key ID and Secret Access Key. Download a key file with
these keys and save it for the future use. Note, that the Access Key file is different from the
Key pair file which you used for the passwordless access to VMs.
b. Copy and paste your credentials into USER_HOME/.aws/credentials and save the file
3. Open the AWS Toolkit on Visual Studio and copy/paste your Access Key and Secret Key:
Now you can see the AWS Explorer panel on the left (if not, Select ‘View’ -> ‘AWS Explorer’)
You can use AWS Explorer to view and manage your resources on AWS. For example, let us list
available Virtual Images (AMIs) available. With this purpose, select ‘Amazon EC2’ and click on
’AMIs’. Wait for the AWS Toolkit to retrieve the list of available VM images:
You can filter images by the type of operating system:
4. Now. Let us deploy your Calculator Service to AWS Elastic Beanstalk Paas. Right Click on the
WcfServiceCalc project and select Publish to AWS Elastic Beanstalk
5. Now you will be guided through the AWS Elastic Beanstalk publish process
a. Create a new application environment using the default account profile. You can change the
region if you wish.
b. Specify the environment name, URL and check its availability.
Note: the default environment name can be already taken by your classmates. So, include
your student id as a part of the name.
c. Configure the AWS options
i. On the AWS Options page, in Amazon EC2 Launch Configuration, from the Container type
drop-down list, choose an Amazon Machine Image (AMI) type that will be used for your
application;
ii. In the Instance type drop-down list, specify an Amazon EC2 instance type to use (use
t2.micro instance which is free tier eligible and will minimize the cost associated with
running the instance);
iii. In the Key pair drop-down list, you can choose an Amazon EC2 instance key pair (if you
have) to use to sign in to the instances for management purpose;
iv. select the Single instance environment box to deploy your application on a single Amazon
EC2 instance
d. Leave default permissions for your instance; you can configure them latter on if you wish
e. Make sure you use the same version of the .NET Runtime environment
f. Deploy your project
g. Wait for the instance being launched and the project being deployed and open the web
service URL
Note: During WS deployment some students can experience errors occurred in the Event list and
related to inability to create an Auto Scaling service.
This can be caused by a recent update in AWS services which affects accounts created after the 1st
of October 2024 - you can find the corresponding message on top of your AWS console.
To fix this issue jump to Alternative AWS Deployment.
Test the WCF Web Service deployed at AWS Elastic Beanstalk
1. Check the WSDL description of a Web Service
2. Use the SoapUI to test your WCF Web Service deployed at AWS Elastic Beanstalk
3. Update the WcfClientCalc client application to invoke the WCF Web Service deployed at AWS
Elastic Beanstalk
4. Logging into AWS management console and explore how the deployed service can be viewed
and managed in the Elastic Beanstalk and EC2 services.
If you wish, you can connect to the Windows virtual instance running your WCF web service via the
RDP.
Step 4: Deleting AWS Elastic Beanstalk resources after use
Log into AWS management console and delete created AWS Elastic Beanstalk environments
and applications. Alternatively, you can delete it using AWS Explore in Visual Studio.
Alternative AWS Beanstalk Deployment
The current workaround solution to deploying your web service with AWS Elastic Beanstalk PaaS
included two stages: (i) Exporting the Web Service app as .zip Web Deploy Package and (ii) Creating
the Beanstalk deployment environment in AWS Console.
Exporting the Web Service app as .zip Web Deploy Package
At the first stage you need to export your Web Service application in Visual Studio to IIS as Web
Deploy Package. As a result you will create a .zip package which can be deployed to AWS Elastic
Beanstalk. Use this guideline:
https://learn.microsoft.com/en-us/visualstudio/deployment/quickstart-deploy-aspnet-web-app?
view=vs-2022&tabs=web-server
Select a location where your package will be selected. It is important that you set the site name to
‘Default Web Site’:
Close and Publish
Check that the .zip package with your application has been created in the specified location.
Creating the Beanstalk deployment environment in AWS Console
At the second stage we need to create the deployment environment directly at AWS Console and
drop our .zipped application there.
Step-1: Open your AWS account
a. Search Elastic Beanstalk service in the search box.
b. Click on the Elastic Beanstalk service
Step-2: Click on “Create environment” button
Fill the configuration environment template with following option
1. select “Web server environment”.
2. Application Name: <write your web app name>
3. Platform -> Managed Platform -> choose .NET on Windows Server
4. Application Code -> select upload your code option
4.1 Version label: <give any name for your application version>
4.2 Local file: Upload your application package exported as zip file at the previous stage
5. Leave the remaining option default and click on the Next button
Step-3
1. Choose “Create and use new service role”
2. Select your key pair values from the drop down menu. We expect that you created these key
pair values in Week-2 Lab. 3. Click on the Next button.
Step 4: Set Up networking, database, and tags - optional
1. Choose VPC <value> from the drop down menu.
2. Select Activated option under Public IP address.
3. Select multiple available zones under Instance subnets. Please check your current zone (or
region) and choose accordingly.
4. Leave the remaining option default and click on the Next button.
Step 5:Configuration instance traffic and scaling - optional
1. Root volume (boot device) -> <choose <General Purpose 3 (SSD)>
2. Update Size : 40 GB
3. Select your <security group name> from the given option. We expect that you created this
security group in Week -2 lab as part of EC2 VM creation.
4. Leave the remaining option default and click on the Next button.
Step 6: Configure updates, monitoring, and logging - optional
1. System -> select Enhanced option
2. CloudWatch Custom Metrics - instance -> choose <ApplicationLatencyP10> from the drop
down menu.
3. CloudWatch Custom Metrics - environment -> choose <ApplicationLatencyP10> from the
drop down menu.
4. Leave the remaining option default and click on the Next button.
Step: 7 Review the configuration and click on the Submit button.
Step 9: Wait until your environment is successfully launched. Check your web service by clicking on
the URL provided.
Click on default.html link