Amazon Web Services Cloud Computing in Delphi
What is cloud computing?
Cloud Computing in Delphi
What is Cloud API provided in Delphi?
Cloud API is the collection of classes that let you integrate your Delphi or C++Builder apps with cloud services like Micorosoft Azure and Amazon Web Services. Contains useful classes that are common across multiple APIs, such as TCloudResponseInfo and TCloudTableRow. Contains the TCloudService class, which is the base service class which the Amazon and Azure API service classes extend.
Difference between AWS and Azure
"Cloud Computing"refers to the on-demand delivery of IT resources and applications via the Internet with pay-as-you-go pricing. You can think of the cloud services as a large scale, publicly accessible collection of compute, storage and networking resources. These are allocated via web service calls using HTTP protocol. In other words it is a „programmable data center” that your applications can integrate with. Cloud Computing providers such as Amazon Web Services own and maintain data centers across the globe with the network-connected hardware required for these application services, while you provision and use only what you need.
RAD Studio provides Cloud components, which allow you to easily use cloud services from Amazon and Microsoft Azure. RAD Studio provides a framework that allows you to build cloud services and easily connect to your back-end services and databases. With the RAD Studio RAD Cloud deployment, you can move your data and services to the Cloud, making your applications accessible from virtually any platform or device from anywhere in the world.
What is Cloud API provided in Delphi?
Cloud API is the collection of classes that let you integrate your Delphi or C++Builder apps with cloud services like Micorosoft Azure and Amazon Web Services. Contains useful classes that are common across multiple APIs, such as TCloudResponseInfo and TCloudTableRow. Contains the TCloudService class, which is the base service class which the Amazon and Azure API service classes extend.
Difference between AWS and Azure
Accessing Amazon Web Services with
Cloud API
The very
first thing in order to start working with cloud services is to create an
account. In case of Amazon Web Services you can do it easily at
http://aws.amazon.com. There is something called a "Free Tier" where
you can experiment with certain services for free for the first year. In order
to access AWS securely you should also have a look at "Identity and Access
Management" service (http://aws.amazon.com/iam).
Simple
Storage Service (S3)
Simple
Database Service (SimpleDB)
Simple Queue
Service (SQS)
How Amazon Web Services work ?
Set up and log
into your AWS account
To use Amazon S3, you need an AWS account. If you don't already
have one, you'll be prompted to create one when you sign up for Amazon S3. You
will not be charged for Amazon S3 until you use it.
Create a bucket
Every object in Amazon S3 is stored in a bucket. Before you can
store data in Amazon S3, you must create a bucket.
Start Building with AWS
Now that you've created a bucket, you're ready to add an object
to it. An object can be any kind of file: a text file, a photo, a video, and so
on. Read the Getting Started Guideto learn more and start building.
Buckets
Keys
Values
Accessing Amazon Web Service in Delphi
using Delphi Cloud API
The AmazonAPI unit is completely new to RAD
Studio. It includes support for the Amazon Simple Queue Service (SQS), Amazon
Simple Storage Service (S3) and Amazon SimpleDB service. These are very similar
to their comparable services offered by Amazon. Amazon API has functions that
will do the XML parsing for you, unless you want to implement that yourself.
The service classes are:
TAmazonTableService,
TAmazonQueueService, TAmazonStorageService. The designer
component for creating a connection info instance is TAmazonConnectionInfo.
The class hierarchy
for Cloud Services in Delphi Tokyo:
TCloudServiceTAmazonService
TAmazonStorageService
TAmazonBasicService
TAmazonTableService
TAmazonQueueService
Cloud Components in Delphi
On the "Cloud" tab you can find "TAmazonConnectionInfo" component that you use to enter your access credentials. In order to access specific functionality of any of the Amazon web services you need to instantiate one of the Cloud API classes that represent a given service passing to a constructor a reference to your TAmazonConnectionInfo component. "CloudAPITest" demo that comes with installation of RAD Studio 10 "Seattle" and illustrates calling all supported methods on these classes.
Connecting to Amazon Web Services
(AWS) Account
We can use
the TAmazonConnectionInfo component
to connect to your Amazon Web Services (AWS) account. Drop the component on the
form and enter your account information in the corresponding properties in the
Object Inspector:
AccountKey:
The Secret Access Key.
AccountName:
The Access Key ID.
Access Keys (Access Key ID and Secret
Access Key)
Access keys
consist of two parts: an access key ID (for example, AKIAIOSFODNN7EXAMPLE) and
a secret access key (for example, wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY).
You use access keys to sign programmatic requests that you make to AWS if you
use AWS CLI commands (using the SDKs) or using AWS API operations. Like a user
name and password, you must use both the access key ID and secret access key
together to authenticate your requests. Manage your access keys as securely as
you do your user name and password. When you create access keys, you create the
access key ID and secret access key as a set. During access key creation, AWS
gives you one opportunity to view and download the secret access key part of
the access key. If you don't download it or if you lose it, you can delete the
access key and then create a new one. And never share the Access key to any one
if you do so then that person have full access to your account.
Alternatively,
we can create an instance of TAmazonConnectionInfo pro-grammatically in Delphi:
var
ConAmazon:TAmazonConnectionInfo ;
….
ConAmazon:= TAmazonConnectionInfo.Create(nil);
ConAmazon.AccountName :=
'AKIAJ32REXDJHV2X4JSQ';
ConAmazon.AccountKey := 'uW3f0fucxqotP/UXQAv/xhiaGt8UAAhHcYDaqxmW';
Using the Amazon Web Services (AWS)
The classes
that implement support for the corresponding Amazon Web Services are:
TAmazonQueueService: Allows you to connect to the Amazon
Simple Queue Service (SQS).
TAmazonTableService: Allows you to connect to the Amazon
SimpleDB service.
TAmazonStorageService: Allows you to connect to the Amazon
Simple Storage Service (S3) service.
Here I have
created examples with using TamazonStorageService to Upload and Download object
to and from Bucket of AWS.
Example…
Upload a Text
procedure
UploadText();
var
ConAmazon:
TAmazonConnectionInfo;
Service: TAmazonStorageService;
Response: TCloudResponseInfo;
Text_Byte: TBytes;
Text_Stream: TStringStream;
bResult : Boolean;
begin
try
//load a string into Buffer of TBytes//
Text_Stream:= TStringStream.Create(‘This
is AWS S3 Demo’);
Text_Byte
:= Text_Stream.Bytes;
//now create AWS connection and storage
object to upload data//
ConAmazon
:= TAmazonConnectionInfo.Create(nil);
ConAmazon.AccountKey :=
'******Secrect-awsACkey**********';
ConAmazon.AccountName :=
*****Secrect-awsACname******';
Service :=
TAmazonStorageService.Create(ConAmazon);
Response
:= TCloudResponseInfo.Create;
bResult:= Service.UploadObject(jkgdelphitext72,
‘testtext72, Text_Byte, False, nil, nil, amzbaPrivate, Response);
if bResult = True then
ShowMessage('Upload
success'+#13+IntToStr(Response.StatusCode)+' -> ' + Response.StatusMessage)
else
ShowMessage('Upload
fails'+#13+IntToStr(Response.StatusCode)+' -> ' + Response.StatusMessage)
Finally
Text_Stream.Free;
Service.Free;
ConAmazon.Free;
end;
end;
Download a Text
procedure
DownloadText();
var
ConAmazon:
TAmazonConnectionInfo;
Service: TAmazonStorageService;
Response: TCloudResponseInfo;
Text_Stream: TStringStream;
bResult : Boolean;
begin
try
//create a String stream with blank//
Text_Stream:= TStringStream.Create;
//now create AWS connection and storage
object to download data//
ConAmazon
:= TAmazonConnectionInfo.Create(nil);
ConAmazon.AccountKey
:= '******Secrect-awsACkey**********';
ConAmazon.AccountName
:= *****Secrect-awsACname******';
Service
:= TAmazonStorageService.Create(ConAmazon);
Response := TCloudResponseInfo.Create;
bResult
:= Service_Storage.GetObject('jkgdelphitext72', 'testtext72', Text_Stream,
Response);
if bResult = True then
begin
memoText.Text := Text_Stream.DataString;
ShowMessage(Download
success'+#13+IntToStr(Response.StatusCode)+' -> ' + Response.StatusMessage);
end
else
ShowMessage(Download fails'+#13+IntToStr(Response.StatusCode)+'
-> ' + Response.StatusMessage)
Finally
Text_Stream.Free;
Service.Free;
ConAmazon.Free;
end;
end;
Upload an Image File
procedure
UploadImage();
var
ConAmazon:
TAmazonConnectionInfo;
Service:
TAmazonStorageService;
Response:
TCloudResponseInfo;
Image_Byte: TBytes;
Image_Stream:
TFileStream;
bResult : Boolean;
begin
try
//load
image into Buffer of TBytes//
Image_Stream:=
TFileStream.Create(‘C:\jitendra\testimage1.png’, 0);
SetLength(Image_Byte,
Image_Stream.Size);
Image_Stream.Position
:= 0;
Image_Stream.Read(Image_Byte,
Image_Stream.Size );
//now
create AWS connection and storage object to upload data//
ConAmazon
:= TAmazonConnectionInfo.Create(nil);
ConAmazon.AccountKey := '******Secrect-awsACkey**********';
ConAmazon.AccountName := *****Secrect-awsACname******';
Service :=
TAmazonStorageService.Create(ConAmazon);
Response := TCloudResponseInfo.Create;
bResult:= Service.UploadObject('jkgdelphiimg72',
‘testimage72’, Image_Byte, False, nil, nil, amzbaPrivate, Response);
if bResult = True then
ShowMessage('Upload success'+#13+IntToStr(Response.StatusCode)+'
-> ' + Response.StatusMessage)
else
ShowMessage('Upload
fails'+#13+IntToStr(Response.StatusCode)+' -> ' + Response.StatusMessage)
Finally
Image_Stream.Free;
Service.Free;
ConAmazon.Free;
end;
end;
Download an Image File
procedure DownloadImage();
var
ConAmazon:
TAmazonConnectionInfo;
Service: TAmazonStorageService;
Response: TCloudResponseInfo;
Image_Stream: TFileStream;
bResult : Boolean;
begin
try
//create a file stream with blank
buffer//
Image_Stream:= TFileStream.Create(‘C:\jitendra\downloadmage1.png’,
fmCreate);
//now create AWS connection and storage
object to upload data//
ConAmazon
:= TAmazonConnectionInfo.Create(nil);
ConAmazon.AccountKey
:= '******Secrect-awsACkey**********';
ConAmazon.AccountName
:= *****Secrect-awsACname******';
Service
:= TAmazonStorageService.Create(ConAmazon);
Response := TCloudResponseInfo.Create;
bResult
:= Service_Storage.GetObject('jkgdelphiimg72', 'testimage72', Image_Stream,
Response);
if bResult = True then
begin
Image1.Picture.LoadFromStream(Image_Stream);
ShowMessage(Download
success'+#13+IntToStr(Response.StatusCode)+' -> ' + Response.StatusMessage);
end
else
ShowMessage(Download fails'+#13+IntToStr(Response.StatusCode)+'
-> ' + Response.StatusMessage)
Finally
Image_Stream.Free;
Service.Free;
ConAmazon.Free;
end;
end;
procedure
btnTextUpLoadClick(Sender: TObject);
begin
UploadText;
end;
procedure
btnImgUploadClick(Sender: TObject);
begin
UploadImage;
end;
procedure
btnTextDownloadClick(Sender: TObject);
begin
DownloadText;
end;
procedure
btnImgDownloadClick(Sender: TObject);
begin
DownloadImage;
end;
procedure
btnTextClearClick(Sender: TObject);
begin
memoText.Clear;
end;
procedure
btnImgClearClick(Sender: TObject);
begin
Image1.Picture := Nil;
end;
Video Tutorial
Learn quickly
how to build Amazon web services with Delphi
https://community.embarcadero.com/blogs/entry/learn-to-quickly-build-amazon-web-services-with-delphi-and-rad-studio
https://community.embarcadero.com/blogs/entry/learn-to-quickly-build-amazon-web-services-with-delphi-and-rad-studio
Some other
examples we can find in Delphi install folder…
C:\Users\Public\Documents\Embarcadero\Studio\19.0\Samples\Object
Pascal\Database\CloudAPI
Deploy the Application to the Cloud
You can
deploy the application to either Amazon EC2 using the Deployment Manager. The
Deployment Manager replaces the formal Deploy to Cloud wizard (for Amazon EC2
infrastructure) shipped with RAD Studio. You can deploy your application to an
Amazon EC2 server just as you would deploy to any other computer. Developers
need to install the Platform Assistant on the EC2 server, then set up a local
profile in RAD Studio with the machine name and port of the server. After that,
developers will be able to deploy to the EC2 server. If the remote debugger is
installed on the EC2 server, then it can be used to debug deployed
applications.
To learn more
about the Deployment Manager, go to http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Deployment_Manager
Useful post, thanks for sharing. I have bookmarked this page for my future reference. Keep up the good work and share more like this.
ReplyDeleteAWS Online Training
Good to hear that it helped you. Please subscribe for new updates.
ReplyDeleteIt is very good and very informative. There is a useful information in it.Thanks for posting...
ReplyDeleteAWS Training In Hyderabad
Great job. If you want to know more about globalcloudteam.com review you should visit this site where there are many interesting information.
ReplyDeleteGreat article...
ReplyDeleteUsually I never comment on blogs but your article is so convincing that I never stop myself to say something about it. You’re doing a great job Man learn AWS Online Training Hyderabad
ReplyDeleteThank you for sharing the post its really knowledgeable.
ReplyDeleteTop Digital Marketing Services
SEO Services
Digital Marketing Services
How to install WordPress
This information is really awesome thanks for sharing most valuable information.
ReplyDeleteRedShift Training
AWS RedShift Training
Amazon RedShift Online Training
APTRON Gurgaon training institute offers you real-time project oriented training on Amazon web services training in Gurgaon in Online and Classroom modes. Our Amazon cloud aws course educational plan designed by top level mentors.
ReplyDeleteFor More Info: AWS Training in Gurgaon
The main motive of the Big Data Implementation Services is to spread the knowledge so that they can give more big data engineers to the world.
ReplyDeleteAWS Training in Chennai
ReplyDeleteAzure Training in Chennai
DevOps Training in Chennai
Nice Blog very use full inormation.AWS-certified experts help you develop a cloud strategy which aligns with your business transformation road map and implement cloud management solutions to harness the AWS Cloud Managed Services
ReplyDeletegreat tips for aws we offer the best aws certification training in california
ReplyDeleteAn awesome blog for the freshers. Thanks for posting this information.
ReplyDeleteWorkday Integration Training
Workday Integration Online Training
These are some great tools that i definitely use for SEO work. This is a great list to use in the future..
ReplyDeletecloud computing security solutions
Really an awesome blog. Your blog is really useful for me.
ReplyDeleteAmazon Web Services Pune
ReplyDeleteIam so thrilled because of finding your alluring website here.Actually i was searching for Amazon Ad Management.Your blog is so astounding and informative too..Iam very happy to find such a creative blog. Iam also find another one by mistake while am searching the same topicAmazon Master Class.Thank you soo much..
Hello, greetings from Teqnico Solutions. We provide complete IT support including React Native mobile app development, software development, web development and design etc. You can reach us through this link: https://www.teqnico.com/what-we-do
ReplyDeleteCan I get some remote works. We are open for partnership program.
Email : info@teqnico.com
This article is a creative one and the concept is good to enhance our knowledge. Waiting for more updates.
ReplyDeleteAWS Online Training
Data Science Online Course
valuable blog,Informative content...thanks for sharing, Waiting for the next update…
ReplyDeleteOnline Kotlin Course
Kotlin Android Developer Online Training
Optimize tech Very efficiently written information. It will be beneficial to anybody who utilizes it, including me. Keep up the good work. For sure i will check out more posts. This site seems to get a good amount of visitors.
ReplyDeleteMuleSoft online training
ReplyDeleteMuleSoft online course
Cognex providesAWS Training in Chennai. Cognex is the best and affordable training institute in Chennai
ReplyDeleteThis is really informative blog, I have to thank for your efforts. Waiting for more post like this.
ReplyDeleteCloud Computing
Benefits of Computing
Cognex offers AWS Training in Chennai using classroom and AWS Online Training globally.
ReplyDeleteThis blog is really helpful for my database. It enhanced the area of my thoughts and pushed me beyond the boundaries. Work ethic of every point is different and represent a new way to improve myself.Managed It Services Company
ReplyDeleteIT's very informative blog and useful article thank you for sharing with us , keep posting learn more about Product engineering services | Product engineering solutions.
ReplyDeleteGreat post! Thanks for sharing this valuable information with us. I am looking forward to reading your more blogs. Multi-cloud offers companies the promise of increased choice, higher availability, and reduced risk for their platform and infrastructure needs. Well if anyone is looking for automated remediations "shoreline" can help you. Shoreline makes it easy to create automated remediations for well-known issues in minutes. It also helps you diagnose and repair new incidents by providing a real-time view of your fleet and the ability to change it safely and securely.
ReplyDeleteThat was really a great Article.Thanks for sharing information. COntinue doing this.
ReplyDeleteDevops Training Online
Devops Online Course
To help businesses of all sizes and industries optimise their use of the cloud and other technologies, Amazon provides a range of business consulting services through their Amazon Web Services (AWS) division.
ReplyDeleteBusiness Consulting Services
amazon consultant
This blog is both informative and entertaining. The author's use of language is excellent and I especially enjoyed the unique insights it provides.
ReplyDeleteaws cloud migration services
Amazon PPC & Advertising Management
ReplyDeleteExcellent insight which is amazing and essential to anyone. I really appreciate you distributing this kind of knowledge. I want to thank you again for sharing that. custom erp developers
ReplyDeleteIf you're new to the world of cloud computing and want to kickstart your journey, APTRON has the perfect solution for you - our comprehensive Beginner's Guide to Amazon Web Services.
ReplyDeleteOne of the main advantage of it's use is time efficiency. Thank you for the further information.
ReplyDeletetop-rated eCommerce and Amazon consulting agency
As the demand for AWS professionals continues to soar, choosing the right training institute is pivotal to your success. APTRON Solutions in Noida stands as a beacon of excellence, empowering individuals to master AWS and thrive in the cloud computing era. Elevate your career with our industry-centric AWS Training Institute in Noida and pave the way for a promising future in the world of cloud technology.
ReplyDelete