Skip to content

Commit 49d0bb7

Browse files
authored
Update run-command.md
add json formatting and add local script path flag to docs
1 parent 3268f1e commit 49d0bb7

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

articles/azure-arc/servers/run-command.md

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,14 @@ New-AzMachineRunCommand -ResourceGroupName MyRG0 -MachineName MyMachine -RunComm
180180

181181
> [!NOTE]
182182
> SAS URL must provide read access to the blob. An expiry time of 24 hours is suggested for SAS URL. SAS URLs can be generated on Azure portal using blob options or SAS token using `New-AzStorageBlobSASToken`. If generating SAS token using `New-AzStorageBlobSASToken`, the SAS URL format is: base blob URL + "?" + the SAS token from `New-AzStorageBlobSASToken`.
183-
>
183+
184+
185+
### Create or update Run Command on a machine using ScriptLocalPath (local script file)
186+
Create or update Run Command on a machine using a local script file that is on the client machine where cmdlet is executed.
187+
188+
```powershell
189+
New-AzMachineRunCommand -ResourceGroupName MyRG0 -VMName MyMachine -RunCommandName MyRunCommand -Location EastUS2EUAP -ScriptLocalPath "C:\MyScriptsDir\MyScript.ps1"
190+
```
184191

185192
### Create or update Run Command on a machine instance using Parameter and ProtectedParameter parameters (Public and Protected Parameters to script)
186193

@@ -224,19 +231,21 @@ Start off by creating a Run Command script to provide endpoint access to the `ww
224231

225232
To directly provide the script in line, use the following operation:
226233

227-
```
234+
```rest
228235
PUT https://management.azure.com/subscriptions/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/resourceGroups/ContosoRG/providers/Microsoft.HybridCompute/machines/2012DatacenterServer1/runCommands/EndpointAccessCommand?api-version=2023-10-03-preview
236+
```
229237

238+
```json
230239
{
231240
"location": "eastus2",
232241
"properties": {
233242
"source": {
234-
"script": " New-NetFirewallRule -DisplayName $ruleName -Direction Outbound -Action Allow -RemoteAddress $endpoint -RemotePort $port -Protocol $protocol
243+
"script": "New-NetFirewallRule -DisplayName $ruleName -Direction Outbound -Action Allow -RemoteAddress $endpoint -RemotePort $port -Protocol $protocol"
235244
},
236245
"parameters": [
237246
{
238247
"name": "ruleName",
239-
"value": " Allow access to www.microsoft.com/pkiops/certs"
248+
"value": "Allow access to www.microsoft.com/pkiops/certs"
240249
},
241250
{
242251
"name": "endpoint",
@@ -254,7 +263,7 @@ PUT https://management.azure.com/subscriptions/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaa
254263
],
255264
"asyncExecution": false,
256265
"runAsUser": "contoso-user1",
257-
"runAsPassword": "Contoso123!
266+
"runAsPassword": "Contoso123!"
258267
"timeoutInSeconds": 3600,
259268
"outputBlobUri": "https://mystorageaccount.blob.core.windows.net/myscriptoutputcontainer/MyScriptoutput.txt",
260269
"errorBlobUri": "https://mystorageaccount.blob.core.windows.net/mycontainer/MyScriptError.txt"
@@ -264,9 +273,11 @@ PUT https://management.azure.com/subscriptions/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaa
264273

265274
To instead link to the script file, you can use the Run Command operation’s ScriptURI option. For this it's assumed you have prepared a `newnetfirewallrule.ps1` file containing the in-line script and uploaded this script to blob storage.
266275

267-
```
276+
```rest
268277
PUT https://management.azure.com/subscriptions/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/resourceGroups/ContosoRG/providers/Microsoft.HybridCompute/machines/2012DatacenterServer1/runCommands/EndpointAccessCommand?api-version=2023-10-03-preview
278+
```
269279

280+
```json
270281
{
271282
"location": "eastus2",
272283
"properties": {
@@ -294,7 +305,7 @@ PUT https://management.azure.com/subscriptions/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaa
294305
],
295306
"asyncExecution": false,
296307
"runAsUser": "contoso-user1",
297-
"runAsPassword": "Contoso123!
308+
"runAsPassword": "Contoso123!"
298309
"timeoutInSeconds": 3600,
299310
"outputBlobUri": "https://mystorageaccount.blob.core.windows.net/myscriptoutputcontainer/MyScriptoutput.txt",
300311
"errorBlobUri": "https://mystorageaccount.blob.core.windows.net/mycontainer/MyScriptError.txt"
@@ -304,13 +315,13 @@ PUT https://management.azure.com/subscriptions/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaa
304315

305316
SAS URL must provide read access to the blob. An expiry time of 24 hours is suggested for SAS URL. SAS URLs can be generated on Azure portal using blobs options or SAS token using `New-AzStorageBlobSASToken`. If generating SAS token using `New-AzStorageBlobSASToken`, the SAS URL format is: `base blob URL + "?"` + the SAS token from `New-AzStorageBlobSASToken`.
306317

307-
Output and error blobs must be the AppendBlob type and their SAS URLs must provide read, append, create, write access to the blob. An expiration time of 24 hours is suggested for SAS URL. SAS URLs can be generated on Azure portal using blob's options, or SAS token from using New-`AzStorageBlobSASToken`.
318+
Output and error blobs must be the AppendBlob type and their SAS URLs must provide read, append, create, write access to the blob. An expiration time of 24 hours is suggested for SAS URL. SAS URLs can be generated on Azure portal using blob's options, or SAS token from using `New-AzStorageBlobSASToken`.
308319

309320
### Example 2: Get Run Command details
310321

311322
To verify that you've correctly provisioned the Run Command, use the GET command to retrieve details on the provisioned Run Command:
312323

313-
```
324+
```rest
314325
GET https://management.azure.com/subscriptions/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/resourceGroups/ContosoRG/providers/Microsoft.HybridCompute/machines/2012DatacenterServer1/runCommands/EndpointAccessCommand?api-version=2023-10-03-preview
315326
```
316327

@@ -319,23 +330,25 @@ GET https://management.azure.com/subscriptions/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaa
319330
Let’s suppose you want to open up access to an additional endpoint `*.waconazure.com` for connectivity to Windows Admin Center. You can update the existing Run Command with new parameters:
320331

321332

322-
```
333+
```rest
323334
PATCH https://management.azure.com/subscriptions/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/resourceGroups/ContosoRG/providers/Microsoft.HybridCompute/machines/2012DatacenterServer1/runCommands/EndpointAccessCommand?api-version=2023-10-03-preview
335+
```
324336

337+
```json
325338
{
326339
"location": "eastus2",
327340
"properties": {
328341
"source": {
329-
"script": " New-NetFirewallRule -DisplayName $ruleName -Direction Outbound -Action Allow -RemoteAddress $endpoint -RemotePort $port -Protocol $protocol
342+
"script": "New-NetFirewallRule -DisplayName $ruleName -Direction Outbound -Action Allow -RemoteAddress $endpoint -RemotePort $port -Protocol $protocol"
330343
},
331344
"parameters": [
332345
{
333346
"name": "ruleName",
334-
"value": " Allow access to WAC endpoint"
347+
"value": "Allow access to WAC endpoint"
335348
},
336349
{
337350
"name": "endpoint",
338-
"value": *.waconazure.com
351+
"value": "*.waconazure.com"
339352
},
340353
{
341354
"name": "port",
@@ -361,15 +374,15 @@ PATCH https://management.azure.com/subscriptions/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaa
361374

362375
Ahead of deleting the Run Command for Endpoint Access, make sure there are no other Run Commands for the Arc-enabled server. You can use the list command to get all of the Run Commands:
363376

364-
```
377+
```rest
365378
LIST https://management.azure.com/subscriptions/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/resourceGroups/ContosoRG/providers/Microsoft.HybridCompute/machines/2012DatacenterServer1/runCommands/
366379
```
367380

368381
### Example 5: Delete a Run Command
369382

370383
If you no longer need the Run Command extension, you can delete it using the following command:
371384

372-
```
385+
```rest
373386
DELETE https://management.azure.com/subscriptions/ aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/resourceGroups/ContosoRG/providers/Microsoft.HybridCompute/machines/2012DatacenterServer1/runCommands/EndpointAccessCommand?api-version=2023-10-03-preview
374387
```
375388

0 commit comments

Comments
 (0)