From fc33133df70d1f8ed11c0791f80d2a3ddfacb3d5 Mon Sep 17 00:00:00 2001 From: Cory Fowler Date: Thu, 2 Aug 2012 00:49:52 -0700 Subject: [PATCH 1/6] initial commit --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..40b878d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ \ No newline at end of file From 7b0e8cf6409b9af57192057fbd0605b271e123ef Mon Sep 17 00:00:00 2001 From: Cory Fowler Date: Thu, 2 Aug 2012 11:21:52 -0700 Subject: [PATCH 2/6] Added Read Service Bus, ensured package.json works --- package.json | 8 ++++++++ program.js | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 package.json create mode 100644 program.js diff --git a/package.json b/package.json new file mode 100644 index 0000000..60045c4 --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "name": "demo-sbreadmessages", + "version": "0.0.1", + "dependencies": { + "azure": ">= 0.6.0", + "commander": ">= 0.6.1" + } +} \ No newline at end of file diff --git a/program.js b/program.js new file mode 100644 index 0000000..54fd83b --- /dev/null +++ b/program.js @@ -0,0 +1,21 @@ +#!/usr/bin/env node + +var program = require('commander'); +var azure = require('azure'); + +var namespace = ''; +var issuer = ''; +var accessKey = ''; + +program.version('0.0.1') + .parse(process.argv); + +var loop = setInterval(function() { + var serviceBus = azure.createServiceBusService(namespace, accessKey, issuer); + serviceBus.receiveQueueMessage('sbmessageme', function(error, serverMessage){ + if(!error){ + console.log(serverMessage.body); + } + }); + }, 10); + From d65a218fe6d7596dd9ac5043e7e49853b3091378 Mon Sep 17 00:00:00 2001 From: Cory Fowler Date: Thu, 2 Aug 2012 13:25:18 -0700 Subject: [PATCH 3/6] structured the folders and added license and readme --- LICENSE.md | 6 +++++ README.md | 37 ++++++++++++++++++++++++--- program.js => code/src/app.js | 0 package.json => code/src/package.json | 0 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 LICENSE.md rename program.js => code/src/app.js (100%) rename package.json => code/src/package.json (100%) diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..f542942 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,6 @@ +Copyright 2012 Microsoft + +The **Demo-SBMessageReader-Nodejs** is licensed under the terms of the Apache License, Version 2.0. +You may use it according to the license as is most appropriate for your project on a case-by-case basis. + +The terms of this license can be found in http://www.apache.org/licenses/LICENSE-2.0 \ No newline at end of file diff --git a/README.md b/README.md index 6d6f6a7..648496c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,35 @@ -Demo-SBMessageReader-Nodejs -=========================== +# Hello Windows Azure # -Node.js Application which reads messages from a Service Bus Queue \ No newline at end of file +## Tutorial ## + +### Introduction ### + +Tutorials are sets of step-by-step guides that are designed to help you learn how to use key Windows Azure services and features. Each tutorial provides instructions to guide you through the process of developing a complete application. + +In this tutorial, you will explore the basic elements of a Windows Azure service by creating a simple GuestBook application that demonstrates many features of Windows Azure, including web and worker roles, blob storage, table storage, and queues. + +> **Note:** You can download the latest build of the Windows Azure Training Kit which includes a tested version of this HOL from here: http://bit.ly/WindowsAzureTK. + +### Repository Structure ### + +In the **root** folder of this repository you will find the tutorial document, **TutorialScript.md**. Before beginning with the HOL exercises, make sure you have followed all the required steps indicated at the setup section of the HOL document. + +In the **Source** folder you will find the source code of each of the exercises, as well as the assets and setup scripts. Throughout the HOL you will be instructed to open and explore the different solutions from the source folder. It is typically comprised of the following subfolders: + +- **Assets:** This folder contains files that are used throughout the exercises. +- **_Exercise Name_:** Each exercise that requires a programming solution has its own code folder. + - **Begin:** The begin solution is the initial incomplete solution that you will finish by following the steps of the corresponding exercise. + - **End:** The end solution is the final result you will achieve at the end of an exercise. +- **Setup:** This folder contains the dependency files and the setup scripts necessary to initialize specific configurations of the tutorial, being its execution is required in the majority of the Tutorials. + +### Get Started ### + +In order to run the solutions of the exercises provided by this tutorial you will first need configure your environment and install any necessary prerequisites such as runtimes, components, or libraries. For your ease, you can download and run the dependency checker [here] (http://go.microsoft.com/fwlink/?LinkId=245702) to automatically check and install all the requirements. Each tutorial also includes setup instructions for getting started. + +### Contributing to the Repository ### + +If you find any issues or opportunities for improving this tutorial, fix them! Feel free to contribute to this project by [forking](http://help.github.com/fork-a-repo/) this repository and make changes to the content. Once you've made your changes, share them back with the community by sending a pull request. Please see [How to send pull requests](http://help.github.com/send-pull-requests/) for more information about contributing to Github projects. + +### Reporting Issues ### + +If you find any issues with this tutorial that you can't fix, feel free to report them in the [issues](https://github.com/WindowsAzure-TrainingKit/Tutorial-HelloWindowsAzure/issues) section of this repository. \ No newline at end of file diff --git a/program.js b/code/src/app.js similarity index 100% rename from program.js rename to code/src/app.js diff --git a/package.json b/code/src/package.json similarity index 100% rename from package.json rename to code/src/package.json From 843efb36e1c54af5f772dab25344be6e134ab6c8 Mon Sep 17 00:00:00 2001 From: Cory Fowler Date: Thu, 2 Aug 2012 13:32:09 -0700 Subject: [PATCH 4/6] updated title --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 648496c..1ccc813 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Hello Windows Azure # +# Demo - Service Bus Message Reader (Node.js) # ## Tutorial ## From d03a2bf4a267313242e0936da288240ca0812d98 Mon Sep 17 00:00:00 2001 From: Cory Fowler Date: Thu, 2 Aug 2012 16:19:16 -0700 Subject: [PATCH 5/6] moved queue name into a variable, added demo.md file for walk through instructions --- Demo.md | 0 code/src/app.js | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 Demo.md diff --git a/Demo.md b/Demo.md new file mode 100644 index 0000000..e69de29 diff --git a/code/src/app.js b/code/src/app.js index 54fd83b..7c74377 100644 --- a/code/src/app.js +++ b/code/src/app.js @@ -6,13 +6,14 @@ var azure = require('azure'); var namespace = ''; var issuer = ''; var accessKey = ''; +var queue = ''; program.version('0.0.1') .parse(process.argv); var loop = setInterval(function() { var serviceBus = azure.createServiceBusService(namespace, accessKey, issuer); - serviceBus.receiveQueueMessage('sbmessageme', function(error, serverMessage){ + serviceBus.receiveQueueMessage(queue, function(error, serverMessage){ if(!error){ console.log(serverMessage.body); } From 08b204b628f55620eadba9cee4413c6060a7553c Mon Sep 17 00:00:00 2001 From: Cory Fowler Date: Sat, 4 Aug 2012 02:33:37 -0700 Subject: [PATCH 6/6] moved service bus variables to external config file --- .gitignore | 7 +++---- code/src/app.js | 12 ++++-------- code/src/config.json | 6 ++++++ 3 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 code/src/config.json diff --git a/.gitignore b/.gitignore index 3fc5bed..cda067a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ -<<<<<<< HEAD -node_modules/ -======= lib-cov *.seed *.log @@ -16,4 +13,6 @@ results node_modules npm-debug.log ->>>>>>> bc49733e950437b002197ca027584a1fdc6d6090 + +config.json + diff --git a/code/src/app.js b/code/src/app.js index 7c74377..575dc01 100644 --- a/code/src/app.js +++ b/code/src/app.js @@ -1,19 +1,15 @@ #!/usr/bin/env node var program = require('commander'); -var azure = require('azure'); - -var namespace = ''; -var issuer = ''; -var accessKey = ''; -var queue = ''; +var azure = require('azure'); +var config = require('./config'); program.version('0.0.1') .parse(process.argv); var loop = setInterval(function() { - var serviceBus = azure.createServiceBusService(namespace, accessKey, issuer); - serviceBus.receiveQueueMessage(queue, function(error, serverMessage){ + var serviceBus = azure.createServiceBusService(config.namespace, config.accessKey, config.issuer); + serviceBus.receiveQueueMessage(config.queue, function(error, serverMessage){ if(!error){ console.log(serverMessage.body); } diff --git a/code/src/config.json b/code/src/config.json new file mode 100644 index 0000000..05d3f61 --- /dev/null +++ b/code/src/config.json @@ -0,0 +1,6 @@ +{ +"namespace": "[sb-namespace]", +"issuer": "[sb-issuer]", +"accessKey": "[sb-access-key]", +"queue": "[sb-queue-name]" +} \ No newline at end of file