/// <summary> /// List all SKUs. /// </summary> /// <remarks> /// List all SKUs. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <SkuInfos> ListSkusAsync(this IWebSiteManagementClient operations, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListSkusWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Gets a list of meters for a given location. /// </summary> /// <remarks> /// Gets a list of meters for a given location. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='billingLocation'> /// Azure Location of billable resource /// </param> /// <param name='osType'> /// App Service OS type meters used for /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <IPage <BillingMeter> > ListBillingMetersAsync(this IWebSiteManagementClient operations, string billingLocation = default(string), string osType = default(string), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListBillingMetersWithHttpMessagesAsync(billingLocation, osType, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Get a list of available geographical regions. /// </summary> /// <remarks> /// Get a list of available geographical regions. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='sku'> /// Name of SKU used to filter the regions. Possible values include: 'Free', /// 'Shared', 'Basic', 'Standard', 'Premium', 'Dynamic', 'Isolated', /// 'PremiumV2', 'ElasticPremium', 'ElasticIsolated' /// </param> /// <param name='linuxWorkersEnabled'> /// Specify <code>true</code> if you want to filter to only regions /// that support Linux workers. /// </param> /// <param name='xenonWorkersEnabled'> /// Specify <code>true</code> if you want to filter to only regions /// that support Xenon workers. /// </param> /// <param name='linuxDynamicWorkersEnabled'> /// Specify <code>true</code> if you want to filter to only regions /// that support Linux Consumption Workers. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <IPage <GeoRegion> > ListGeoRegionsAsync(this IWebSiteManagementClient operations, string sku = default(string), bool?linuxWorkersEnabled = default(bool?), bool?xenonWorkersEnabled = default(bool?), bool?linuxDynamicWorkersEnabled = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListGeoRegionsWithHttpMessagesAsync(sku, linuxWorkersEnabled, xenonWorkersEnabled, linuxDynamicWorkersEnabled, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Get a list of available geographical regions. /// </summary> /// <remarks> /// Get a list of available geographical regions. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='nextPageLink'> /// The NextLink from the previous successful call to List operation. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <IPage <GeoRegion> > ListGeoRegionsNextAsync(this IWebSiteManagementClient operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ListGeoRegionsNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Updates source control token /// </summary> /// <remarks> /// Updates source control token /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='sourceControlType'> /// Type of source control /// </param> /// <param name='requestMessage'> /// Source control token information /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <SourceControl> UpdateSourceControlAsync(this IWebSiteManagementClient operations, string sourceControlType, SourceControl requestMessage, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.UpdateSourceControlWithHttpMessagesAsync(sourceControlType, requestMessage, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Updates publishing user /// </summary> /// <remarks> /// Updates publishing user /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='userDetails'> /// Details of publishing user /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <User> UpdatePublishingUserAsync(this IWebSiteManagementClient operations, User userDetails, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.UpdatePublishingUserWithHttpMessagesAsync(userDetails, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
private static Site GetFromCache(IWebSiteManagementClient client, string website) { Site site = Cache.GetSite(client.Credentials.SubscriptionId, website); if (site != null) { // Verify site still exists try { WebSiteGetParameters input = new WebSiteGetParameters(); input.PropertiesToInclude.Add("repositoryuri"); input.PropertiesToInclude.Add("publishingpassword"); input.PropertiesToInclude.Add("publishingusername"); return(client.WebSites.Get(site.WebSpace, site.Name, input).ToSite()); } catch { // Website is removed or webspace changed, remove from cache Cache.RemoveSite(client.Credentials.SubscriptionId, site); throw; } } return(null); }
/// <summary> /// Validate if the container settings are correct. /// </summary> /// <remarks> /// Validate if the container settings are correct. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='validateContainerSettingsRequest'> /// </param> /// <param name='resourceGroupName'> /// Name of the resource group to which the resource belongs. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <object> ValidateContainerSettingsAsync(this IWebSiteManagementClient operations, ValidateContainerSettingsRequest validateContainerSettingsRequest, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ValidateContainerSettingsWithHttpMessagesAsync(validateContainerSettingsRequest, resourceGroupName, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Validate if a resource can be created. /// </summary> /// <remarks> /// Validate if a resource can be created. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// Name of the resource group to which the resource belongs. /// </param> /// <param name='validateRequest'> /// Request with the resources to validate. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <ValidateResponse> ValidateAsync(this IWebSiteManagementClient operations, string resourceGroupName, ValidateRequest validateRequest, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ValidateWithHttpMessagesAsync(resourceGroupName, validateRequest, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// The Get Operation Status operation returns the status of the /// specified operation. After calling a long-running operation, you /// can call Get Operation Status to determine whether the operation /// has succeeded, failed, timed out, or is still in progress. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/ee460783.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.WebSites.IWebSiteManagementClient. /// </param> /// <param name='webSpaceName'> /// Required. The name of the webspace for the website where the /// operation was targeted. /// </param> /// <param name='siteName'> /// Required. The name of the site where the operation was targeted. /// </param> /// <param name='operationId'> /// Required. The operation ID for the operation you wish to track. The /// operation ID is returned in the ID field in the body of the /// response for long-running operations. /// </param> /// <returns> /// The response body contains the status of the specified long-running /// operation, indicating whether it has succeeded, is inprogress, has /// timed out, or has failed. Note that this status is distinct from /// the HTTP status code returned for the Get Operation Status /// operation itself. If the long-running operation failed, the /// response body includes error information regarding the failure. /// </returns> public static WebSiteOperationStatusResponse GetOperationStatus(this IWebSiteManagementClient operations, string webSpaceName, string siteName, string operationId) { return(Task.Factory.StartNew((object s) => { return ((IWebSiteManagementClient)s).GetOperationStatusAsync(webSpaceName, siteName, operationId); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// Unregister your subscription to use Azure Web Sites. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.WebSites.IWebSiteManagementClient. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static OperationResponse UnregisterSubscription(this IWebSiteManagementClient operations) { return(Task.Factory.StartNew((object s) => { return ((IWebSiteManagementClient)s).UnregisterSubscriptionAsync(); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// Begins deleting a resource group. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.WebSites.IWebSiteManagementClient. /// </param> /// <param name='resourceGroupName'> /// Required. The name of the resource group. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static OperationResponse BeginDeletingResourceGroup(this IWebSiteManagementClient operations, string resourceGroupName) { return(Task.Factory.StartNew((object s) => { return ((IWebSiteManagementClient)s).BeginDeletingResourceGroupAsync(resourceGroupName); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
internal AzureWebSiteManager(string webSpace = AzureServiceConstants.DefaultWebSpace) { WebSiteManagementClient = new WebSiteManagementClient(Dependencies.Subscription.Credentials, new Uri(Dependencies.Subscription.CoreEndpointUrl)); var webSpaces = WebSiteManagementClient.WebSpaces.ListAsync(new CancellationToken()).Result; if (!webSpaces.Any(s => s.Name.Equals(webSpace, StringComparison.InvariantCultureIgnoreCase))) { webSpace = webSpaces.First().Name; } _webSpace = webSpace; }
/// <summary> /// Unregister your subscription to use Windows Azure Web Sites. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.WebSites.IWebSiteManagementClient. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static OperationResponse UnregisterSubscription(this IWebSiteManagementClient operations) { try { return(operations.UnregisterSubscriptionAsync().Result); } catch (AggregateException ex) { if (ex.InnerExceptions.Count > 1) { throw; } else { throw ex.InnerException; } } }
/// <summary> /// The Get Operation Status operation returns the status of /// thespecified operation. After calling a long-running operation, /// you can call Get Operation Status to determine whether the /// operation has succeeded, failed, timed out, or is still in /// progress. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/ee460783.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.WebSites.IWebSiteManagementClient. /// </param> /// <param name='webSpaceName'> /// The name of the webspace for the website where the operation was /// targeted. /// </param> /// <param name='siteName'> /// The name of the site where the operation was targeted. /// </param> /// <param name='operationId'> /// The operation ID for the operation you wish to track. The operation /// ID is returned in the Id field in the body of the response for /// long-running operations. /// </param> /// <returns> /// The response body contains the status of the specified long-running /// operation, indicating whether it has succeeded, is inprogress, has /// time dout, or has failed. Note that this status is distinct from /// the HTTP status code returned for the Get Operation Status /// operation itself. If the long-running operation failed, the /// response body includes error information regarding the failure. /// </returns> public static WebSiteOperationStatusResponse GetOperationStatus(this IWebSiteManagementClient operations, string webSpaceName, string siteName, string operationId) { try { return(operations.GetOperationStatusAsync(webSpaceName, siteName, operationId).Result); } catch (AggregateException ex) { if (ex.InnerExceptions.Count > 1) { throw; } else { throw ex.InnerException; } } }
private static async Task <CertificateInner> UploadCertificate( IWebSiteManagementClient client, string resourceGroup, string appName, string appSlot, PfxBuilder pfx, string thumbprint) { var pfxName = string.Format(CultureInfo.InvariantCulture, "[certes] {0:yyyyMMddhhmmss}", DateTime.UtcNow); var pfxPassword = Guid.NewGuid().ToString("N"); var pfxBytes = pfx.Build(pfxName, pfxPassword); var webApp = string.IsNullOrWhiteSpace(appSlot) ? await client.WebApps.GetAsync(resourceGroup, appName) : await client.WebApps.GetSlotAsync(resourceGroup, appName, appSlot); var certData = new CertificateInner { PfxBlob = pfxBytes, Password = pfxPassword, Location = webApp.Location, }; return(await client.Certificates.CreateOrUpdateAsync( resourceGroup, thumbprint, certData)); }
private static async Task <CertificateInner> FindCertificate( IWebSiteManagementClient client, string resourceGroup, string thumbprint) { var certificates = await client.Certificates.ListByResourceGroupAsync(resourceGroup); while (certificates != null) { foreach (var azCert in certificates) { if (string.Equals(azCert.Thumbprint, thumbprint, StringComparison.OrdinalIgnoreCase)) { return(azCert); } } certificates = certificates.NextPageLink == null ? null : await client.Certificates.ListByResourceGroupNextAsync(certificates.NextPageLink); } return(null); }
private static async Task <WebApp> GetWebApp(IWebSiteManagementClient client, WebSite site) { var currentConfig = await client.WebSites.GetConfigurationAsync(site.WebSpace, site.Name, CancellationToken.None); var settings = currentConfig.AppSettings.Select(d => new Setting { Key = d.Key, Value = d.Value, IsSql = false }) .ToList(); var connectionStrings = currentConfig.ConnectionStrings.Select(MapConnectionStringToSetting).ToList(); var webApp = new WebApp { Name = site.Name, WebSpace = site.WebSpace, AppSettings = settings, ConnectionStrings = connectionStrings, FtpSettings = GetFtpSettings(site, currentConfig) }; return(webApp); }
private static Site GetFromAzure(IWebSiteManagementClient client, string website) { // Get all available webspace using REST API var spaces = client.WebSpaces.List(); foreach (var space in spaces.WebSpaces) { WebSiteListParameters input = new WebSiteListParameters(); input.PropertiesToInclude.Add("repositoryuri"); input.PropertiesToInclude.Add("publishingpassword"); input.PropertiesToInclude.Add("publishingusername"); var sites = client.WebSpaces.ListWebSites(space.Name, input); var site = sites.WebSites.FirstOrDefault( ws => ws.Name.Equals(website, StringComparison.InvariantCultureIgnoreCase)); if (site != null) { return(site.ToSite()); } } // The website does not exist. return(null); }
/// <summary> /// Validate if the container settings are correct. /// </summary> /// <remarks> /// Validate if the container settings are correct. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='validateContainerSettingsRequest'> /// </param> /// <param name='resourceGroupName'> /// Name of the resource group to which the resource belongs. /// </param> public static object ValidateContainerSettings(this IWebSiteManagementClient operations, ValidateContainerSettingsRequest validateContainerSettingsRequest, string resourceGroupName) { return(operations.ValidateContainerSettingsAsync(validateContainerSettingsRequest, resourceGroupName).GetAwaiter().GetResult()); }
/// <summary> /// Validate if a resource can be created. /// </summary> /// <remarks> /// Validate if a resource can be created. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// Name of the resource group to which the resource belongs. /// </param> /// <param name='validateRequest'> /// Request with the resources to validate. /// </param> public static ValidateResponse Validate(this IWebSiteManagementClient operations, string resourceGroupName, ValidateRequest validateRequest) { return(operations.ValidateAsync(resourceGroupName, validateRequest).GetAwaiter().GetResult()); }
private static Site GetFromAzure(IWebSiteManagementClient client, string website) { // Get all available webspace using REST API var spaces = client.WebSpaces.List(); foreach (var space in spaces.WebSpaces) { WebSiteListParameters input = new WebSiteListParameters(); input.PropertiesToInclude.Add("repositoryuri"); input.PropertiesToInclude.Add("publishingpassword"); input.PropertiesToInclude.Add("publishingusername"); var sites = client.WebSpaces.ListWebSites(space.Name, input); var site = sites.WebSites.FirstOrDefault( ws => ws.Name.Equals(website, StringComparison.InvariantCultureIgnoreCase)); if (site != null) { return site.ToSite(); } } // The website does not exist. return null; }
public static Site GetSiteWithCache( this IWebSiteManagementClient client, string website) { return(GetFromCache(client, website) ?? GetFromAzure(client, website)); }
/// <summary> /// List all premier add-on offers. /// </summary> /// <remarks> /// List all premier add-on offers. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='nextPageLink'> /// The NextLink from the previous successful call to List operation. /// </param> public static IPage <PremierAddOnOffer> ListPremierAddOnOffersNext(this IWebSiteManagementClient operations, string nextPageLink) { return(operations.ListPremierAddOnOffersNextAsync(nextPageLink).GetAwaiter().GetResult()); }
private static Site GetFromCache(IWebSiteManagementClient client, string website) { Site site = Cache.GetSite(client.Credentials.SubscriptionId, website); if (site != null) { // Verify site still exists try { WebSiteGetParameters input = new WebSiteGetParameters(); input.PropertiesToInclude.Add("repositoryuri"); input.PropertiesToInclude.Add("publishingpassword"); input.PropertiesToInclude.Add("publishingusername"); return client.WebSites.Get(site.WebSpace, site.Name, input).ToSite(); } catch { // Website is removed or webspace changed, remove from cache Cache.RemoveSite(client.Credentials.SubscriptionId, site); throw; } } return null; }
/// <summary> /// List all apps that are assigned to a hostname. /// </summary> /// <remarks> /// List all apps that are assigned to a hostname. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='nextPageLink'> /// The NextLink from the previous successful call to List operation. /// </param> public static IPage <Identifier> ListSiteIdentifiersAssignedToHostNameNext(this IWebSiteManagementClient operations, string nextPageLink) { return(operations.ListSiteIdentifiersAssignedToHostNameNextAsync(nextPageLink).GetAwaiter().GetResult()); }
/// <summary> /// Updates publishing user /// </summary> /// <remarks> /// Updates publishing user /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='userDetails'> /// Details of publishing user /// </param> public static User UpdatePublishingUser(this IWebSiteManagementClient operations, User userDetails) { return(operations.UpdatePublishingUserAsync(userDetails).GetAwaiter().GetResult()); }
/// <summary> /// Verifies if this VNET is compatible with an App Service Environment by /// analyzing the Network Security Group rules. /// </summary> /// <remarks> /// Verifies if this VNET is compatible with an App Service Environment by /// analyzing the Network Security Group rules. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='parameters'> /// VNET information /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <VnetValidationFailureDetails> VerifyHostingEnvironmentVnetAsync(this IWebSiteManagementClient operations, VnetParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.VerifyHostingEnvironmentVnetWithHttpMessagesAsync(parameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Get a list of available geographical regions. /// </summary> /// <remarks> /// Get a list of available geographical regions. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='nextPageLink'> /// The NextLink from the previous successful call to List operation. /// </param> public static IPage <GeoRegion> ListGeoRegionsNext(this IWebSiteManagementClient operations, string nextPageLink) { return(operations.ListGeoRegionsNextAsync(nextPageLink).GetAwaiter().GetResult()); }
/// <summary> /// Gets the source controls available for Azure websites. /// </summary> /// <remarks> /// Gets the source controls available for Azure websites. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='nextPageLink'> /// The NextLink from the previous successful call to List operation. /// </param> public static IPage <SourceControl> ListSourceControlsNext(this IWebSiteManagementClient operations, string nextPageLink) { return(operations.ListSourceControlsNextAsync(nextPageLink).GetAwaiter().GetResult()); }
/// <summary> /// Validate whether a resource can be moved. /// </summary> /// <remarks> /// Validate whether a resource can be moved. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// Name of the resource group to which the resource belongs. /// </param> /// <param name='moveResourceEnvelope'> /// Object that represents the resource to move. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task ValidateMoveAsync(this IWebSiteManagementClient operations, string resourceGroupName, CsmMoveResourceEnvelope moveResourceEnvelope, CancellationToken cancellationToken = default(CancellationToken)) { (await operations.ValidateMoveWithHttpMessagesAsync(resourceGroupName, moveResourceEnvelope, null, cancellationToken).ConfigureAwait(false)).Dispose(); }
/// <summary> /// Validate whether a resource can be moved. /// </summary> /// <remarks> /// Validate whether a resource can be moved. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// Name of the resource group to which the resource belongs. /// </param> /// <param name='moveResourceEnvelope'> /// Object that represents the resource to move. /// </param> public static void ValidateMove(this IWebSiteManagementClient operations, string resourceGroupName, CsmMoveResourceEnvelope moveResourceEnvelope) { operations.ValidateMoveAsync(resourceGroupName, moveResourceEnvelope).GetAwaiter().GetResult(); }