internal async Task <bool> ConfigureAgentProxy( string ownerUri, string accountName, AgentProxyInfo proxy, AgentConfigAction configAction) { return(await Task <bool> .Run(() => { try { ConnectionInfo connInfo; ConnectionServiceInstance.TryFindConnection( ownerUri, out connInfo); CDataContainer dataContainer = AdminService.CreateDataContainer(connInfo, databaseExists: true); STParameters param = new STParameters(dataContainer.Document); param.SetParam("proxyaccount", accountName); using (AgentProxyAccount agentProxy = new AgentProxyAccount(dataContainer, proxy)) { if (configAction == AgentConfigAction.Create) { return agentProxy.Create(); } else if (configAction == AgentConfigAction.Update) { return agentProxy.Update(); } else if (configAction == AgentConfigAction.Drop) { return agentProxy.Drop(); } else { return false; } } } catch (Exception) { // log exception here return false; } })); }