-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathimportRegistrationsJob.poller.js
More file actions
46 lines (38 loc) · 1.5 KB
/
importRegistrationsJob.poller.js
File metadata and controls
46 lines (38 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/**
* This sample demonstrates how the createNotificationJob() method can be used to import registrations
* descriptions from an existing set of exports.
*
* See https://learn.microsoft.com/azure/notification-hubs/export-modify-registrations-bulk
* to learn about Export and Import Registrations in Azure Notification Hubs.
*
*
* @summary Demonstrates how to import registrations into a Notification Hub.
*/
require("dotenv/config");
const {
beginSubmitNotificationHubJob,
createClientContext,
} = require("@azure/notification-hubs/api");
// Define connection string and hub name
const connectionString = process.env.NOTIFICATIONHUBS_CONNECTION_STRING || "<connection string>";
const hubName = process.env.NOTIFICATION_HUB_NAME || "<hub name>";
// Define export job parameters
const outputContainerUrl = process.env.OUTPUT_CONTAINER_URL || "<output container URL>";
const importFileUrl = process.env.IMPORT_FILE_URL || "<import file URL>";
async function main() {
const context = createClientContext(connectionString, hubName);
let importJob = {
outputContainerUrl,
importFileUrl,
type: "ImportCreateRegistrations",
};
const poller = await beginSubmitNotificationHubJob(context, importJob);
importJob = await poller.pollUntilDone();
console.log(`Notification Hub Job status: ${importJob.status}`);
}
main().catch((err) => {
console.log("exportRegistrationJob Sample: Error occurred: ", err);
process.exit(1);
});