0

I am sending api request using python requests library.

The code as follows;

subscription_id =os.environ['AZURE_SUBSCRIPTION_ID']
source="https://management.azure.com"
token_context=access_token()
tokens=json.loads(token_context.text)
token=tokens['access_token']

headers = {'Authorization': 'Bearer ' +token, 
'Content-Type': 'application/json'}

data={
    "commandId": "RunShellScript",
    "script":["urlAdresstoScriptStoredinBlobStorage"]}

api="{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.Compute/virtualMachines/{}/runCommand?api-version=2021-11-01".format(
    source,subscription_id,vmRG,vmName)

response = requests.post(api,json=data,headers=headers)
return response

The Error I got:

"error": {
  "code": "Conflict",
  "message": "Run command OS type 'Linux' does not match the target OS Windows."

}

What could be the source of the error and how to solve it?

Any suggestion is appreciated, Thanks.

Hilal
  • 41
  • 7
  • 2
    I think you're having the opposite problem to [this](https://stackoverflow.com/q/69239102/7867968). You'll want to `RunPowerShellScript` rather than `RunShellScript` – C.Nivs Feb 28 '22 at 16:13
  • @C.Nivs Thanks a lot. Changing commandId solved it – Hilal Mar 01 '22 at 09:25

0 Answers0