/// <summary>
 /// Create a connection.  (see
 /// http://aka.ms/azureautomationsdk/connectionoperations for more
 /// information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Automation.IConnectionOperations.
 /// </param>
 /// <param name='automationAccount'>
 /// Required. The automation account name.
 /// </param>
 /// <param name='parameters'>
 /// Required. The parameters supplied to the create connection
 /// operation.
 /// </param>
 /// <returns>
 /// The response model for the create connection operation.
 /// </returns>
 public static ConnectionCreateResponse Create(this IConnectionOperations operations, string automationAccount, ConnectionCreateParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IConnectionOperations)s).CreateAsync(automationAccount, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
        public Connection CreateConnection(string automationAccountName, string name, string connectionTypeName, IDictionary connectionFieldValues,
            string description)
        {
            var connectionModel = this.TryGetConnectionModel(automationAccountName, name);
            if (connectionModel != null)
            {
                throw new ResourceCommonException(typeof(Connection),
                    string.Format(CultureInfo.CurrentCulture, Resources.ConnectionAlreadyExists, name));
            }

            var ccprop = new ConnectionCreateProperties()
            {
                Description = description,
                ConnectionType = new ConnectionTypeAssociationProperty() { Name = connectionTypeName },
                FieldDefinitionValues = connectionFieldValues.Cast<DictionaryEntry>().ToDictionary(kvp => kvp.Key.ToString(), kvp => kvp.Value.ToString())
            };

            var ccparam = new ConnectionCreateParameters() { Name = name, Properties = ccprop };

            var connection = this.automationManagementClient.Connections.Create(automationAccountName, ccparam).Connection;

            return new Connection(automationAccountName, connection);
        }
 /// <summary>
 /// Create a connection.  (see
 /// http://aka.ms/azureautomationsdk/connectionoperations for more
 /// information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Automation.IConnectionOperations.
 /// </param>
 /// <param name='automationAccount'>
 /// Required. The automation account name.
 /// </param>
 /// <param name='parameters'>
 /// Required. The parameters supplied to the create connection
 /// operation.
 /// </param>
 /// <returns>
 /// The response model for the create connection operation.
 /// </returns>
 public static Task<ConnectionCreateResponse> CreateAsync(this IConnectionOperations operations, string automationAccount, ConnectionCreateParameters parameters)
 {
     return operations.CreateAsync(automationAccount, parameters, CancellationToken.None);
 }