|
1 | | -# Azure LoadTest client library for JavaScript |
| 1 | +# Azure Load Testing client library for JavaScript |
2 | 2 |
|
3 | 3 | This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure LoadTest client. |
4 | 4 |
|
@@ -64,6 +64,109 @@ const client = new LoadTestClient(new DefaultAzureCredential(), subscriptionId); |
64 | 64 | // const client = new LoadTestClient(credential, subscriptionId); |
65 | 65 | ``` |
66 | 66 |
|
| 67 | +### Create an Azure Load Testing resource |
| 68 | + |
| 69 | +Create a new Azure Load Testing resource. |
| 70 | +```javascript |
| 71 | +loadTestResourceCreatePayload = { |
| 72 | + location: "westus2" |
| 73 | +}; |
| 74 | + |
| 75 | +const resource = await client.loadTests.beginCreateOrUpdateAndWait( |
| 76 | + "sample-rg", |
| 77 | + "sample-loadtesting-resource", |
| 78 | + loadTestResourceCreatePayload |
| 79 | +); |
| 80 | + |
| 81 | +console.log(resource); |
| 82 | +``` |
| 83 | + |
| 84 | +Create a new Azure Load Testing resource with managed identity and customer managed key encryption. |
| 85 | +```javascript |
| 86 | +loadTestResourceCreatePayload = { |
| 87 | + location: "westus2", |
| 88 | + tags: { team: "testing" }, |
| 89 | + identity: { |
| 90 | + type: 'SystemAssigned, UserAssigned', |
| 91 | + userAssignedIdentities: { |
| 92 | + '/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/sample-rg/providers/microsoft.managedidentity/userassignedidentities/identity1': {} |
| 93 | + } |
| 94 | + }, |
| 95 | + encryption: { |
| 96 | + identity: { |
| 97 | + type: 'UserAssigned', |
| 98 | + resourceId: '/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/sample-rg/providers/microsoft.managedidentity/userassignedidentities/identity1' |
| 99 | + }, |
| 100 | + keyUrl: 'https://sample-kv.vault.azure.net/keys/cmkkey/2d1ccd5c50234ea2a0858fe148b69cde' |
| 101 | + } |
| 102 | +}; |
| 103 | + |
| 104 | +const resource = await client.loadTests.beginCreateOrUpdateAndWait( |
| 105 | + "sample-rg", |
| 106 | + "sample-loadtesting-resource", |
| 107 | + loadTestResourceCreatePayload |
| 108 | +); |
| 109 | + |
| 110 | +console.log(resource); |
| 111 | +``` |
| 112 | + |
| 113 | +### Get an Azure Load Testing resource |
| 114 | + |
| 115 | +```javascript |
| 116 | +let resourceName = 'sample-loadtesting-resource'; |
| 117 | +let resourceGroupName = 'sample-rg'; |
| 118 | + |
| 119 | +const resource = await client.loadTests.get( |
| 120 | + resourceGroupName, |
| 121 | + resourceName |
| 122 | +); |
| 123 | + |
| 124 | +console.log(resource); |
| 125 | +``` |
| 126 | + |
| 127 | +### Update an Azure Load Testing resource |
| 128 | + |
| 129 | +```javascript |
| 130 | +loadTestResourcePatchPayload = { |
| 131 | + tags: { team: "testing-dev" }, |
| 132 | + identity: { |
| 133 | + type: 'SystemAssigned, UserAssigned', |
| 134 | + userAssignedIdentities: { |
| 135 | + // removing a user-assigned managed identity by assigning the value in the payload as null |
| 136 | + '/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/sample-rg/providers/microsoft.managedidentity/userassignedidentities/identity1': null, |
| 137 | + '/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/sample-rg/providers/microsoft.managedidentity/userassignedidentities/identity2': {} |
| 138 | + } |
| 139 | + }, |
| 140 | + encryption: { |
| 141 | + // use system-assigned managed identity for CMK encryption |
| 142 | + identity: { |
| 143 | + type: 'SystemAssigned', |
| 144 | + resourceId: null |
| 145 | + }, |
| 146 | + keyUrl: 'https://sample-kv.vault.azure.net/keys/cmkkey/2d1ccd5c50234ea2a0858fe148b69cde' |
| 147 | + } |
| 148 | +}; |
| 149 | + |
| 150 | +const resource = await client.loadTests.beginUpdateAndWait( |
| 151 | + "sample-rg", |
| 152 | + "sample-loadtesting-resource", |
| 153 | + loadTestResourcePatchPayload |
| 154 | +); |
| 155 | + |
| 156 | +console.log(resource); |
| 157 | +``` |
| 158 | + |
| 159 | +### Delete an Azure Load Testing resource |
| 160 | + |
| 161 | +```javascript |
| 162 | +let resourceName = 'sample-loadtesting-resource'; |
| 163 | +let resourceGroupName = 'sample-rg'; |
| 164 | + |
| 165 | +const result = await client.loadTests.beginDeleteAndWait( |
| 166 | + resourceGroupName, |
| 167 | + resourceName |
| 168 | +); |
| 169 | +``` |
67 | 170 |
|
68 | 171 | ### JavaScript Bundle |
69 | 172 | To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling). |
|
0 commit comments