diff --git a/sdk/servicebus/service-bus/samples/javascript/useProxy.js b/sdk/servicebus/service-bus/samples/javascript/useProxy.js index da46486997e7..b551d8b6e206 100644 --- a/sdk/servicebus/service-bus/samples/javascript/useProxy.js +++ b/sdk/servicebus/service-bus/samples/javascript/useProxy.js @@ -18,6 +18,7 @@ require("dotenv").config(); // Define connection string for your Service Bus instance here const connectionString = process.env.SERVICE_BUS_CONNECTION_STRING || ""; +const queueName = process.env.QUEUE_NAME || ""; async function main() { const proxyInfo = process.env.HTTP_PROXY || process.env.HTTPS_PROXY; @@ -36,14 +37,18 @@ async function main() { // No need to pass the `WebSocket` from "ws" package if you're in the browser // in which case the `window.WebSocket` is used by the library. webSocket: WebSocket, - webSocketConstructorOptions: { agent: proxyAgent } - } + webSocketConstructorOptions: { agent: proxyAgent }, + }, + }); + + const sender = sbClient.createSender(queueName); + + console.log(`Sending message using proxy server ${proxyInfo}`); + + await sender.send({ + body: "sample message", }); - /* - Refer to other samples, and place your code here - to create queue clients, and to send/receive messages - */ await sbClient.close(); } diff --git a/sdk/servicebus/service-bus/samples/typescript/src/useProxy.ts b/sdk/servicebus/service-bus/samples/typescript/src/useProxy.ts index 305a8be169dd..c22423ffd798 100644 --- a/sdk/servicebus/service-bus/samples/typescript/src/useProxy.ts +++ b/sdk/servicebus/service-bus/samples/typescript/src/useProxy.ts @@ -12,7 +12,7 @@ import { ServiceBusClient } from "@azure/service-bus"; import WebSocket from "ws"; -import HttpsProxyAgent from "https-proxy-agent"; +import { HttpsProxyAgent } from "https-proxy-agent"; // Load the .env file if it exists import * as dotenv from "dotenv"; @@ -20,9 +20,11 @@ dotenv.config(); // Define connection string for your Service Bus instance here const connectionString = process.env.SERVICE_BUS_CONNECTION_STRING || ""; +const queueName = process.env.QUEUE_NAME || ""; export async function main() { const proxyInfo = process.env.HTTP_PROXY || process.env.HTTPS_PROXY; + if (!proxyInfo) { console.error( "Error: Proxy information not provided, but it is required to run this sample. Exiting." @@ -38,14 +40,18 @@ export async function main() { // No need to pass the `WebSocket` from "ws" package if you're in the browser // in which case the `window.WebSocket` is used by the library. webSocket: WebSocket, - webSocketConstructorOptions: { agent: proxyAgent } - } + webSocketConstructorOptions: { agent: proxyAgent }, + }, + }); + + const sender = sbClient.createSender(queueName); + + console.log(`Sending message using proxy server ${proxyInfo}`); + + await sender.send({ + body: "sample message", }); - /* - Refer to other samples, and place your code here - to create queue clients, and to send/receive messages - */ await sbClient.close(); } diff --git a/sdk/servicebus/service-bus/samples/typescript/tsconfig.json b/sdk/servicebus/service-bus/samples/typescript/tsconfig.json index 18985e1b1051..db1651fcc966 100644 --- a/sdk/servicebus/service-bus/samples/typescript/tsconfig.json +++ b/sdk/servicebus/service-bus/samples/typescript/tsconfig.json @@ -4,8 +4,8 @@ "target": "ES2015", "moduleResolution": "node", - "allowSyntheticDefaultImports": true, - + "esModuleInterop": true, + "lib": ["ESNext.AsyncIterable"], "outDir": "dist", "rootDir": "src" },