public async Task <ScaleUnitEnvironmentConfiguration> WriteScaleUnitConfiguration(ScaleUnitEnvironmentConfiguration config) { var msg = new HttpRequestMessage(HttpMethod.Post, $"{requestPathPrefix}api/services/ScaleUnitInitializationServiceGroup/ScaleUnitInitializationService/configureScaleUnit/"); var serializedConfig = Newtonsoft.Json.JsonConvert.SerializeObject(config); // Wrap in object that allows the AOS to map in to method params on the service class. var writePayload = $"{{\"configuration\": {serializedConfig},\"runSync\": true}}"; msg.Content = new StringContent(writePayload, Encoding.UTF8, "application/json"); var response = await httpClient.SendAsync(msg); string result = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { ScaleUnitEnvironmentConfiguration parsed = Newtonsoft.Json.JsonConvert.DeserializeObject <ScaleUnitEnvironmentConfiguration>(result); return(parsed); } else { throw RequestFailure((int)response.StatusCode, result); } }
private async Task ConfigureScaleUnit() { await EnsureClientInitialized(); await ReliableRun.Execute(async() => { ScaleUnitEnvironmentConfiguration configuration = await scaleUnitAosClient.WriteScaleUnitConfiguration(ScaleUnitConfig); configuration.Should().NotBeNull("The AOS should have returned the configuration"); configuration.WithDeepEqual(ScaleUnitConfig).IgnoreSourceProperty((property) => property.HubS2SEncryptedSecret).Assert(); configuration.HubS2SEncryptedSecret.Should().NotBe(ScaleUnitConfig.HubS2SEncryptedSecret, "Secret should have been encrypted by the AOS."); }, "Scale unit configuration"); }
public HubConfigurationManager() { scaleUnit = Config.FindScaleUnitWithId(ScaleUnitContext.GetScaleUnitId()); hubConfig = new ScaleUnitEnvironmentConfiguration() { AppId = Config.InterAOSAppId(), AppTenant = Config.InterAOSAuthority(), HubResourceId = Config.InterAOSAppResourceId(scaleUnit), HubUrl = scaleUnit.Endpoint(), HubS2SEncryptedSecret = Config.InterAOSAppSecret(), ScaleUnitType = "0", }; }