We can read yaml file within Runspace using code given in below post
How to read remote yaml file present in Azure VM from local machine using C# Runspace
But how to update existing remotely located yaml file.
I want to use code using YamlDotnet similar to one given in below post to create some new data to be updated into existing yaml file.
Build a Yaml document dynamically from c#
Update:
I have inventory yaml file with its contents as below
targets:
- uri: 80.587.459.478
config:
transport: ssh
ssh:
user: testlinuxuname
private-key: ~/ssh-key/SSH-PrivateKey.txt
host-key-check: false
run-as: root
- uri: targetwindows123
config:
transport: winrm
winrm:
user: testusername
password: testpwd
ssl-verify: false
Yaml file is located in remote Azure VM.
Requirement: I want to read
yamlfile which is present in remote azure vm fromC#and check if particularurivalue exists or not. If particularurivalue doesn't exist, then I need to append newuridata toyamlfile. So new record will be appended next to existing data inyamlfile.New record will be something like below.
- uri: targetwindows567 config: transport: winrm winrm: user: testusername1 password: testpwd1 ssl-verify: falseI want to check if
urivaluetargetwindows567exists or not inyamlfile. If it don't exist, then add above records into the remoteyamlfile.