private void NewProfile()
        {
            var cdnProfile = CdnManagementClient.Profiles.Create(
                ProfileName,
                new ProfileCreateParameters(
                    Location,
                    new SdkSku(Sku.CastEnum <PSSkuName, SdkSkuName>()),
                    Tags.ToDictionaryTags()),
                ResourceGroupName);

            WriteObject(cdnProfile.ToPsProfile());
        }
        public override void ExecuteCmdlet()
        {
            // NewAzureCdnProfile should not overwrite any existing profiles, so check if the profile exist first
            // before creation.
            try
            {
                CdnManagementClient.Profiles.GetWithHttpMessagesAsync(ProfileName, ResourceGroupName)
                .Wait();
                throw new PSArgumentException(string.Format(Resources.Error_CreateExistingProfile, ProfileName,
                                                            ResourceGroupName));
            }
            catch (AggregateException exception)
            {
                var errorResponseException = exception.InnerException as ErrorResponseException;
                if (errorResponseException == null)
                {
                    throw;
                }

                if (errorResponseException.Response.StatusCode.Equals(HttpStatusCode.NotFound))
                {
                    var cdnProfile = CdnManagementClient.Profiles.Create(
                        ProfileName,
                        new ProfileCreateParameters(
                            Location,
                            new SdkSku(Sku.CastEnum <PSSkuName, SdkSkuName>()),
                            Tags.ToDictionaryTags()),
                        ResourceGroupName);

                    WriteObject(cdnProfile.ToPsProfile());
                }
                else
                {
                    throw;
                }
            }
        }