public async Task <bool> SetCapacityAsync(int capacity) { var client = new ArmClient(await this.GetConfigurationInfo().GetAccessToken()); ActorState State = await StateManager.GetStateAsync <ActorState>(StateKey); if (!State.IsInitialized) { return(false); } if (State.Capacity != capacity) { var queue = await ClusterConfigStore.GetMessageClusterResourceAsync(Id.GetStringId()) as ClusterProcessorNode; var obj = await client.PatchAsync(State.VMSSResourceId, new JObject( new JProperty("location", queue.Properties.Location), new JProperty("sku", new JObject( new JProperty("capacity", capacity), new JProperty("name", queue.Properties.Name), new JProperty("tier", queue.Properties.Tier) )) ), "2016-03-30"); State.Capacity = obj.SelectToken("sku.capacity").ToObject <int>(); State.LastScaleAction = DateTimeOffset.UtcNow; await StateManager.SetStateAsync(StateKey, State); await StartProvisionReminderAsync(); return(true); } return(false); }