This C# sample demonstrates how to call the Google Cloud Pub/Sub API from C#.
This sample requires .NET Core 2.0 or later. That means using Visual Studio 2017, or the command line. Visual Studio 2015 users can use this older sample.
-
Follow the instructions in the root README.
-
Enable APIs for your project. Click here to visit Cloud Platform Console and enable the Google Stackdriver Cloud Pub/Sub API.
-
Edit QuickStart.cs, and replace YOUR-PROJECT-ID with the id of the project you created in step 1.
-
From a Powershell command line, run the QuickStart sample:
PS C:\...\dotnet-docs-samples\pubsub\api\QuickStart> dotnet restore PS C:\...\dotnet-docs-samples\pubsub\api\QuickStart> dotnet run Topic projects/YOUR-PROJECT-ID/topics/my-new-topic created. -
And run the Pubsub sample to see a list of subcommands like createTopic and createSubscription:
PS C:\...\dotnet-docs-samples\pubsub\api\PubsubSample> dotnet restore PS C:\...\dotnet-docs-samples\pubsub\api\PubsubSample> dotnet run Pubsub 1.0.0.0 Copyright c Google Inc. 2017 ERROR(S): No verb selected. createTopic Create a pubsub topic in this project. createSubscription Create a pubsub subscription in this project. createTopicMessage Create a pubsub topic message in this project. pullTopicMessages Pull pubsub messages in this project. getTopic Get the details of a pubsub topic in this project. getSubscription Get the details of a pubsub subscription in this project. getTopicIamPolicy Get the IAM policy of a topic in this project. getSubscriptionIamPolicy Get the IAM policy of a subscription in this project. setTopicIamPolicy Set the IAM policy of a topic in this project. setSubscriptionIamPolicy Set the IAM policy of a subscription in this project. listProjectTopics List the pubsub topics in this project. listSubscriptions List the pubsub subscriptions in this project. deleteSubscription Delete a pubsub subscription in this project. deleteTopic Delete a pubsub topic in this project. help Display more information on a specific command. version Display version information.
- See CONTRIBUTING.md
- See LICENSE
- See TESTING.md