0

I'm trying launch an instance with a startup script in the compute engine .net API. Here's the code I'm using-

var start = new Google.Apis.Compute.v1.Data.Metadata.ItemsData();
start.Key = "startup-script";
start.Value = "C:\\Users\\User\\Desktop\\script.sh";
newinst.Metadata = new Google.Apis.Compute.v1.Data.Metadata();
newinst.Metadata.Items = new List<Google.Apis.Compute.v1.Data.Metadata.ItemsData>();
newinst.Metadata.Items.Add(start);

and this is my script-

#! /bin/sh
gsutil cp gs://bucket/file dir

dir is an existing directory in the image. The instance launches but there's no trace of that command being run.

further info: from looking at log info it looks like a script is found in metadata and the instance thinks it's running it but no commands are executed

Ross Manson
  • 339
  • 1
  • 3
  • 14

1 Answers1

1

For anyone interested, what I needed here was to add-

newinst.Metadata.Kind = "compute#metadata";

before executing the InsertRequest or it won't use the script.

Ross Manson
  • 339
  • 1
  • 3
  • 14