Skip to content

Commit 6b93f9e

Browse files
committed
update file with latest sdk
1 parent 4372e4c commit 6b93f9e

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

articles/cdn/cdn-app-dev-node.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ You will then be presented a series of questions to initialize your project. Fo
4343

4444
![NPM init output](./media/cdn-app-dev-node/cdn-npm-init.png)
4545

46-
Our project is now initialized with a *packages.json* file. Our project is going to use some Azure libraries contained in NPM packages. We'll use the library for Azure Active Directory authentication in Node.js (@azure/ms-rest-nodeauth) and the Azure CDN Client Library for JavaScript (@azure/arm-cdn). Let's add those to the project as dependencies.
46+
Our project is now initialized with a *packages.json* file. Our project is going to use some Azure libraries contained in NPM packages. We'll use the library for Azure Active Directory authentication in Node.js (@azure/identity) and the Azure CDN Client Library for JavaScript (@azure/arm-cdn). Let's add those to the project as dependencies.
4747

4848
```console
49-
npm install --save @azure/ms-rest-nodeauth
49+
npm install --save @azure/identity
5050
npm install --save @azure/arm-cdn
5151
```
5252

@@ -64,8 +64,8 @@ After the packages are done installing, the *package.json* file should look simi
6464
"author": "Cam Soper",
6565
"license": "MIT",
6666
"dependencies": {
67-
"@azure/arm-cdn": "^5.2.0",
68-
"@azure/ms-rest-nodeauth": "^3.0.0"
67+
"@azure/arm-cdn": "^7.0.1",
68+
"@azure/identity": "^2.0.4"
6969
}
7070
}
7171
```
@@ -78,7 +78,7 @@ With *app.js* open in our editor, let's get the basic structure of our program w
7878
1. Add the "requires" for our NPM packages at the top with the following:
7979

8080
``` javascript
81-
var msRestAzure = require('@azure/ms-rest-nodeauth');
81+
const { DefaultAzureCredential } = require("@azure/identity");
8282
const { CdnManagementClient } = require('@azure/arm-cdn');
8383
```
8484
2. We need to define some constants our methods will use. Add the following. Be sure to replace the placeholders, including the **<angle brackets>**, with your own values as needed.
@@ -97,7 +97,7 @@ With *app.js* open in our editor, let's get the basic structure of our program w
9797
3. Next, we'll instantiate the CDN management client and give it our credentials.
9898
9999
``` javascript
100-
var credentials = new msRestAzure.ApplicationTokenCredentials(clientId, tenantId, clientSecret);
100+
var credentials = new DefaultAzureCredential();
101101
var cdnClient = new CdnManagementClient(credentials, subscriptionId);
102102
```
103103
@@ -246,7 +246,7 @@ function cdnCreate() {
246246
}
247247
248248
// create profile <profile name>
249-
function cdnCreateProfile() {
249+
async function cdnCreateProfile() {
250250
requireParms(3);
251251
console.log("Creating profile...");
252252
var standardCreateParameters = {
@@ -256,11 +256,11 @@ function cdnCreateProfile() {
256256
}
257257
};
258258
259-
cdnClient.profiles.create( resourceGroupName, parms[2], standardCreateParameters, callback);
259+
await cdnClient.profiles.beginCreateAndWait( resourceGroupName, parms[2], standardCreateParameters, callback);
260260
}
261261
262262
// create endpoint <profile name> <endpoint name> <origin hostname>
263-
function cdnCreateEndpoint() {
263+
async function cdnCreateEndpoint() {
264264
requireParms(5);
265265
console.log("Creating endpoint...");
266266
var endpointProperties = {
@@ -271,7 +271,7 @@ function cdnCreateEndpoint() {
271271
}]
272272
};
273273
274-
cdnClient.endpoints.create(resourceGroupName, parms[2], parms[3], endpointProperties, callback);
274+
await cdnClient.endpoints.beginCreateAndWait(resourceGroupName, parms[2], parms[3], endpointProperties, callback);
275275
}
276276
```
277277

@@ -280,34 +280,34 @@ Assuming the endpoint has been created, one common task that we might want to pe
280280

281281
```javascript
282282
// purge <profile name> <endpoint name> <path>
283-
function cdnPurge() {
283+
async function cdnPurge() {
284284
requireParms(4);
285285
console.log("Purging endpoint...");
286286
var purgeContentPaths = [ parms[3] ];
287-
cdnClient.endpoints.purgeContent(resourceGroupName, parms[2], parms[3], purgeContentPaths, callback);
287+
await cdnClient.endpoints.beginPurgeContentAndWait(resourceGroupName, parms[2], parms[3], purgeContentPaths, callback);
288288
}
289289
```
290290

291291
## Delete CDN profiles and endpoints
292292
The last function we will include deletes endpoints and profiles.
293293

294294
```javascript
295-
function cdnDelete() {
295+
async function cdnDelete() {
296296
requireParms(2);
297297
switch(parms[1].toLowerCase())
298298
{
299299
// delete profile <profile name>
300300
case "profile":
301301
requireParms(3);
302302
console.log("Deleting profile...");
303-
cdnClient.profiles.deleteMethod(resourceGroupName, parms[2], callback);
303+
await cdnClient.profiles.beginDeleteAndWait(resourceGroupName, parms[2], callback);
304304
break;
305305

306306
// delete endpoint <profile name> <endpoint name>
307307
case "endpoint":
308308
requireParms(4);
309309
console.log("Deleting endpoint...");
310-
cdnClient.endpoints.deleteMethod(resourceGroupName, parms[2], parms[3], callback);
310+
await cdnClient.endpoints.beginDeleteAndWait(resourceGroupName, parms[2], parms[3], callback);
311311
break;
312312

313313
default:

0 commit comments

Comments
 (0)