[Music]
hi this is Shahab with Amazon Web
Services in this section we are going to
take a look at how to use Amazon simple
notification services or SNS in your
dotnet application now let's take a
deeper look at Amazon simple
notification service Amazon simple
notification service can be used by the
publisher to push messages to a topic
and these messages can be pushed to
subscribers such as AWS services like
lambda sqs or Jarek endpoints such as
HTTP you can even push email or SMS to
the clients so let's take a look at some
characteristics of Amazon SNS each
notification message contains a single
published message message order is not
guaranteed and a message cannot be
deleted after it is published also you
can use SNS delivery policy to control
retries in case of message delivery
failure another important point is that
messages can contain up to 256 kilobytes
of data of text data including XML JSON
and unformatted text let's take a look
at some of Amazon SNS operations that
you can use through the API you can
create a topic you can subscribe to a
topic publish data to a topic delete a
topic and there is this whole list of
actions then you can find at the URL I
provided below the screen now let's take
a look at the demo how to use SNS api's
in your dotnet application using visual
studio in your microsoft visual studio
you can see the a SS Explorer on the
left side you can actually expand the
Amazon SNS and it will show me what
topics I have at the moment you can
right click on Amazon SNS and create a
topic or view subscriptions for the
purpose of this demo let's create an
application to use the SNS
P is let's go to file new project from
AWS samples you should be able to see
app services click on app services and
click on AWS SNS sample and then click
ok it asks you to set the profile and
region for your application so now I'm
going to use my default for a while and
I'm going to use the North Virginia
which is the US East one region click OK
and here is the application this is a
console application so everything
happens in this application in the
program that CS before taking a look at
the program that CS let's take a look at
the dependencies in the dependencies
under NuGet packages you should be able
to see a SS SDK simple notification
service remember that if you are
creating a new application from scratch
one thing you can do is to right-click
on dependencies manage new get packages
and search for a SS SDK dot simple
notification services and it will find
this for you here since I have it
installed I can uninstall or update it
but you will see an option to install it
if you want to do it in a brand new
application also in the app that config
you should be able to see the profile
and region so if you need to change the
region you can do it here in your
application let's go back to the program
that CS which is the start point of our
console application you can see Amazon
that simple notification service and
Amazon that simple notification service
that model library is imported here if
you are creating a brand new application
you need to import these libraries let's
take a look at the code
in order to use Amazon simple
notification service you need to create
a client this client should be of type
Amazon simple notification service
client now you have the client create
you can do multiple actions using the
client you can use SNS that create topic
and you should have a create topic
request it create topic request requires
a name for the topic the create topic
response includes the topic arm you can
use that topic arm to set the topic
attributes in these examples we are
setting the topic attributes to have a
display name and some value and let's
call it simple notifications for.net
also using the client you can list all
the topics and using a list topic
request and also you can get topic
attributes using the kit get topic
attribute API and get topic attributes
requests and for the get wrath the topic
attribute requests you need to provide
the topic arm that you got when you
created the topic
after you created the topic you need to
subscribe the topic to an end point in
this scenario we are subscribing the
topic to an email address please make
sure that after you subscribe it to an
email address the email user actually
needs to confirm the subscription or you
cannot actually push emails to their
substitute to the client and at last you
can publish the message using the
publish API and a publish request there
is like to test a subject and message
and let's change this message and say
let's hello from AWS and you need to
provide the topic iron as well and the
last operation you can see here is the
delete topic that you will use a delete
topic request for that and for deleting
a topic as mentioned before you need to
provide the topic iron now let's run the
application click on debug and start
without debugging so I have previously
created an email which is called test
AWS services it first asked me provide
an email address I'm going to provide
test AWS services and press Enter what
it does it creates a topic and
subscribes it to my email address but
until I confirm the subscription I
cannot publish or push messages to it
let's go back to my email you can see
that hey there is an email from AWS
and which asks you to confirm the
subscription let's confirm the
subscription here now it says that you
have subscribes your email to the topics
sample SNS topic let's go back as you
can see the code is running let's take a
look at visual studio and let's expand
the view we had on the AWS Explorer and
refresh it we can see that a new topic
called sample SNS topic is created here
let's go back to the console and now
press Enter it says after you you're
subscribed press enter
let's press Enter since that publishing
message to topic and please check your
email we go back to my email we go back
to inbox and see hey this is hello from
AWS that we pushed from our code so as
you can see using the.net application we
did create a topic subscribe it to my
email address and push a message to my
email address
let's click enter now what it does it
deletes the topic and let's press enter
to exit so if i refresh my view since i
deleted the topic that topic is gone so
this is how you use Amazon SNS api's in
your dotnet application I hope you
enjoyed this video about how to use SNS
api's in your dotnet application thanks
for watching
[Music]