|
| 1 | +<h3>Azure UpdateManager Copilot Studio Flow - OneTimeUpdate</h3> |
| 2 | + |
| 3 | +<img src="./images/1 start.png" alt="1" width="800" > |
| 4 | + |
| 5 | +Click on "+" and create "Initialize Variable" : |
| 6 | + |
| 7 | +<img src="./images/2 query graph.png" alt="2" width="800" > |
| 8 | + |
| 9 | +Call the variable "querygraph", set it as a String and past the following query as a value: |
| 10 | + |
| 11 | +```querygraph |
| 12 | +resources |
| 13 | +| where name =~ "@{triggerBody()?['text']}" |
| 14 | +``` |
| 15 | + |
| 16 | +Click again on "+" and select again "Initialize Variable", call it "apiversion" : |
| 17 | + |
| 18 | +<img src="./images/3 create api version varaible.png" alt="3" width="800" > |
| 19 | + |
| 20 | +After the variables creation place an "HTTP request" block and fill all the required information: |
| 21 | + |
| 22 | +<img src="./images/4 HTTP Request.png" alt="HTTPRequest" width="800" > |
| 23 | + |
| 24 | +<img src="./images/4-1 HTTP request.png" alt="HTTPRequest4-1" width="800" > |
| 25 | + |
| 26 | +After HTTP request creation place and Parse JSON block and use the "body" output as a content. |
| 27 | + |
| 28 | +<img src="./images/5 parse json.png" alt="parseJSON" width="800" > |
| 29 | + |
| 30 | +Copy and past the schema: |
| 31 | + |
| 32 | +```schema |
| 33 | +{ |
| 34 | + "properties": { |
| 35 | + "extendedLocation": {}, |
| 36 | + "id": { |
| 37 | + "type": "string" |
| 38 | + }, |
| 39 | + "identity": {}, |
| 40 | + "kind": { |
| 41 | + "type": "string" |
| 42 | + }, |
| 43 | + "location": { |
| 44 | + "type": "string" |
| 45 | + }, |
| 46 | + "managedBy": { |
| 47 | + "type": "string" |
| 48 | + }, |
| 49 | + "name": { |
| 50 | + "type": "string" |
| 51 | + }, |
| 52 | + "plan": {}, |
| 53 | + "properties": { |
| 54 | + "properties": { |
| 55 | + "classifications": { |
| 56 | + "items": { |
| 57 | + "type": "string" |
| 58 | + }, |
| 59 | + "type": "array" |
| 60 | + }, |
| 61 | + "kbId": { |
| 62 | + "type": "string" |
| 63 | + }, |
| 64 | + "lastModifiedDateTime": { |
| 65 | + "type": "string" |
| 66 | + }, |
| 67 | + "patchId": { |
| 68 | + "type": "string" |
| 69 | + }, |
| 70 | + "patchName": { |
| 71 | + "type": "string" |
| 72 | + }, |
| 73 | + "publishedDateTime": { |
| 74 | + "type": "string" |
| 75 | + }, |
| 76 | + "rebootBehavior": { |
| 77 | + "type": "string" |
| 78 | + } |
| 79 | + }, |
| 80 | + "type": "object" |
| 81 | + }, |
| 82 | + "resourceGroup": { |
| 83 | + "type": "string" |
| 84 | + }, |
| 85 | + "sku": {}, |
| 86 | + "subscriptionId": { |
| 87 | + "type": "string" |
| 88 | + }, |
| 89 | + "tags": {}, |
| 90 | + "tenantId": { |
| 91 | + "type": "string" |
| 92 | + }, |
| 93 | + "type": { |
| 94 | + "type": "string" |
| 95 | + }, |
| 96 | + "zones": {} |
| 97 | + }, |
| 98 | + "type": "object" |
| 99 | +} |
| 100 | +``` |
| 101 | + |
| 102 | +Now we need to create a "machineid" variable, paste the code below inside the value : |
| 103 | + |
| 104 | +<img src="./images/6 machineid.png" alt="6" width="800" > |
| 105 | + |
| 106 | +```function |
| 107 | +body('Parse_JSON')?['data']?[0]?['id'] |
| 108 | +``` |
| 109 | + |
| 110 | +Create a condition block: |
| 111 | + |
| 112 | +<img src="./images/7 condition.png" alt="7" width="800" > |
| 113 | + |
| 114 | +In the false section set the variable "api version azmv" following the example: |
| 115 | + |
| 116 | +<img src="./images/7 false.png" alt="7" width="800" > |
| 117 | + |
| 118 | +In the True section set the variable "api version ARC" following the example: |
| 119 | + |
| 120 | +<img src="./images/7 true.png" alt="7" width="800" > |
| 121 | + |
| 122 | +Create invoke resource operation and fill the required parameters following the example: |
| 123 | + |
| 124 | +<img src="./images/8 invoke resource.png" alt="8" width="800" > |
| 125 | + |
| 126 | +```code |
| 127 | +Subscritpion: body('Parse_JSON')?['data']?[0]?['subscriptionId'] |
| 128 | +Resource Group: body('Parse_JSON')?['data']?[0]?['resourceGroup'] |
| 129 | +Resource Provider: first(split(body('Parse_JSON')?['data']?[0]?['type'], '/')) |
| 130 | +Short Resource ID: machines/@{triggerBody()?['text']} |
| 131 | +Client Api Version: @{variables('apiversion')} |
| 132 | +Action name: installPatches |
| 133 | +
|
| 134 | +Body: |
| 135 | +{ |
| 136 | + "maximumDuration": "PT120M", |
| 137 | + "rebootSetting": "IfRequired", |
| 138 | + "windowsParameters": { |
| 139 | + "classificationsToInclude": [ |
| 140 | + "Security", |
| 141 | + "UpdateRollup", |
| 142 | + "FeaturePack", |
| 143 | + "ServicePack", |
| 144 | + "Critical", |
| 145 | + "Definition", |
| 146 | + "Tools", |
| 147 | + "Updates" |
| 148 | + ] |
| 149 | + } |
| 150 | +} |
| 151 | +``` |
| 152 | +Now we need to create a "StatusCode" variable : |
| 153 | + |
| 154 | +<img src="./images/9 status code.png" alt="9" width="800" > |
| 155 | + |
| 156 | +Create a condition block: |
| 157 | + |
| 158 | +<img src="./images/10 condition.png" alt="7" width="800" > |
| 159 | + |
| 160 | +In the false section set the variable "StatusCode" following the example: |
| 161 | + |
| 162 | +<img src="./images/10 false.png" alt="10" width="800" > |
| 163 | + |
| 164 | +In the True section set the variable "StatusCode" following the example: |
| 165 | + |
| 166 | +<img src="./images/10 true.png" alt="10" width="800" > |
| 167 | + |
| 168 | +Finally we can paste the output to Copilot Agent: |
| 169 | + |
| 170 | +<img src="./images/11 end.png" alt="11" width="800" > |
| 171 | + |
| 172 | +As a final step, save and publish the flow. The entire logic flow must appear like that: |
| 173 | + |
| 174 | +<img src="./images/flow3.png" alt="flow" width="600" > |
| 175 | + |
| 176 | +Go back to continue [Configuration Link](../../README.md#flow3) |
| 177 | + |
0 commit comments