Parameters supplied to the CreateOrUpdate Identity Provider operation.
 /// <summary>
 /// Creates new or update existing identity provider configuration.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.ApiManagement.IIdentityProviderOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='serviceName'>
 /// Required. The name of the Api Management service.
 /// </param>
 /// <param name='identityProviderName'>
 /// Required. Identifier of the identity provider.
 /// </param>
 /// <param name='parameters'>
 /// Required. Create parameters.
 /// </param>
 /// <returns>
 /// A standard service response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static AzureOperationResponse Create(this IIdentityProviderOperations operations, string resourceGroupName, string serviceName, string identityProviderName, IdentityProviderCreateParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IIdentityProviderOperations)s).CreateAsync(resourceGroupName, serviceName, identityProviderName, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
        public void IdentityProviderCreateListUpdateDelete()
        {
            TestUtilities.StartTest("SmapiFunctionalTests", "IdentityProviderCreateListUpdateDelete");

            try
            {
                // create facebook external identity provider
                string clientId = TestUtilities.GenerateName("clientId");
                string clientSecret = TestUtilities.GenerateName("clientSecret");

                var identityProviderCreateParameters = new IdentityProviderCreateParameters(clientId, clientSecret);

                var createResponse = ApiManagementClient.IdentityProvider.Create(
                    ResourceGroupName,
                    ApiManagementServiceName,
                    IdentityProviderTypeContract.Facebook.ToString("g"),
                    identityProviderCreateParameters);

                Assert.NotNull(createResponse);
                Assert.Equal(HttpStatusCode.Created, createResponse.StatusCode);

                // get to check it was created
                var getResponse = ApiManagementClient.IdentityProvider.Get(ResourceGroupName, ApiManagementServiceName, IdentityProviderTypeContract.Facebook.ToString("g"));

                Assert.NotNull(getResponse);
                Assert.NotNull(getResponse.Value);
                Assert.NotNull(getResponse.Value.ClientId);
                Assert.NotNull(getResponse.Value.ClientSecret);
                Assert.Equal(IdentityProviderTypeContract.Facebook, getResponse.Value.Type);

                var listIdentityProviders = ApiManagementClient.IdentityProvider.List(ResourceGroupName, ApiManagementServiceName, null);

                Assert.NotNull(listIdentityProviders);
                Assert.NotNull(listIdentityProviders.Result);

                // there should be one identity Provider
                Assert.True(listIdentityProviders.Result.Count >= 1);

                // patch identity provider
                string patchedSecret = TestUtilities.GenerateName("clientSecret");
                var patchResponse = ApiManagementClient.IdentityProvider.Update(
                    ResourceGroupName,
                    ApiManagementServiceName,
                    IdentityProviderTypeContract.Facebook.ToString("g"),
                    new IdentityProviderUpdateParameters
                    {
                        ClientSecret = patchedSecret
                    }, 
                    getResponse.ETag);

                Assert.NotNull(patchResponse);

                // get to check it was patched
                getResponse = ApiManagementClient.IdentityProvider.Get(ResourceGroupName, ApiManagementServiceName, IdentityProviderTypeContract.Facebook.ToString("g"));

                Assert.NotNull(getResponse);
                Assert.NotNull(getResponse.Value);
                Assert.Equal(IdentityProviderTypeContract.Facebook, getResponse.Value.Type);
                Assert.Equal(patchedSecret, getResponse.Value.ClientSecret);

                // delete the identity provider
                var deleteResponse = ApiManagementClient.IdentityProvider.Delete(
                    ResourceGroupName,
                    ApiManagementServiceName,
                    IdentityProviderTypeContract.Facebook.ToString("g"),
                    getResponse.ETag);

                Assert.NotNull(deleteResponse);
                Assert.Equal(HttpStatusCode.NoContent, deleteResponse.StatusCode);

                // get the deleted identity provider to make sure it was deleted
                try
                {
                    ApiManagementClient.IdentityProvider.Get(ResourceGroupName, ApiManagementServiceName, IdentityProviderTypeContract.Facebook.ToString("g"));
                    throw new Exception("This code should not have been executed.");
                }
                catch (CloudException ex)
                {
                    Assert.Equal(HttpStatusCode.NotFound, ex.Response.StatusCode);
                }
            }
            finally
            {
                TestUtilities.EndTest();
            }
        }
 /// <summary>
 /// Creates new or update existing identity provider configuration.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.ApiManagement.IIdentityProviderOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='serviceName'>
 /// Required. The name of the Api Management service.
 /// </param>
 /// <param name='identityProviderName'>
 /// Required. Identifier of the identity provider.
 /// </param>
 /// <param name='parameters'>
 /// Required. Create parameters.
 /// </param>
 /// <returns>
 /// A standard service response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static Task<AzureOperationResponse> CreateAsync(this IIdentityProviderOperations operations, string resourceGroupName, string serviceName, string identityProviderName, IdentityProviderCreateParameters parameters)
 {
     return operations.CreateAsync(resourceGroupName, serviceName, identityProviderName, parameters, CancellationToken.None);
 }