PEAKUP.Azure.Services 1.0.5

dotnet add package PEAKUP.Azure.Services --version 1.0.5                
NuGet\Install-Package PEAKUP.Azure.Services -Version 1.0.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PEAKUP.Azure.Services" Version="1.0.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PEAKUP.Azure.Services --version 1.0.5                
#r "nuget: PEAKUP.Azure.Services, 1.0.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PEAKUP.Azure.Services as a Cake Addin
#addin nuget:?package=PEAKUP.Azure.Services&version=1.0.5

// Install PEAKUP.Azure.Services as a Cake Tool
#tool nuget:?package=PEAKUP.Azure.Services&version=1.0.5                

PEAKUP.Azure.Services

PEAKUP.Azure.Services is a .NET Core project that provides a set of services for scaling Azure resources such as Web Apps and SQL databases. It leverages the Azure Management Fluent SDK to interact with Azure resources.

Getting Started

  1. Create an Azure Application

    • Go to the Azure portal (https://portal.azure.com).
    • Navigate to "Azure Active Directory" in the left-hand menu.
    • Click on "App registrations" and then click "New registration".
    • Provide a name for the application, select the supported account types, and specify the redirect URI (if required).
  2. Assign Access Control (IAM) Permissions

    • For Web App Management:

      1. Navigate to the desired resource group that contains the target Web App.
      2. Click on "Access control (IAM)" in the left-hand menu.
      3. Click "Add a role assignment".
      4. In the "Role" dropdown, search for and select "Web Plan Contributor" and "Website Contributor".
      5. In the "Select" dropdown, search and select the application you created in Step 1.
      6. Click "Save" to assign the roles.
    • For SQL Server and Database Management:

      1. Navigate to the desired resource group that contains the target SQL Server and database.
      2. Click on "Access control (IAM)" in the left-hand menu.
      3. Click "Add a role assignment".
      4. In the "Role" dropdown, search for and select "SQL DB Contributor", "SQL Managed Instance Contributor", and "SQL Server Contributor".
      5. In the "Select" dropdown, search and select the application you created in Step 1.
      6. Click "Save" to assign the roles.
  3. Update Application Credentials in the Code

    In the Program.cs file of the PEAKUP.Azure.Services project, update the following variables with the values obtained from Step 1:

    var credentials = new AzureApplicationCredentials()
    {
        ClientId = "Your_Client_Id",        // Replace with the Application (client) ID
        ClientSecret = "Your_Client_Secret",    // Replace with the Client secret
        TenantId = "Your_Tenant_Id",        // Replace with the Directory (tenant) ID
        SubscriptionId = "Your_Subscription_Id"    // Replace with your Azure subscription ID
    };
    
    
    

Prerequisites

  • .NET 6.0 LTS or later
  • Azure subscription with appropriate permissions and credentials

Installation

  1. Clone the repository or download the source code.
  2. Open the solution in Visual Studio or your preferred code editor.

Configuration

Before running the application, make sure to update the Azure application credentials and resource information in the Program.cs file.

// Update these values with your actual Azure application credentials
var credentials = new AzureApplicationCredentials()
{
    ClientId = "Your_Client_Id",
    ClientSecret = "Your_Client_Secret",
    TenantId = "Your_Tenant_Id",
    SubscriptionId = "Your_Subscription_Id"
};

// Update these values with your actual Azure resource information
var webAppResources = new WebAppCredentials()
{
    ResourceGroupName = "Your_Resource_Group",
    WebAppName = "Your_Web_App_Name",
    WebAppServicePlanName = "Your_Web_App_Service_Plan_Name"
};

var sqlResources = new SQLCredentials()
{
    ResourceGroupName = "Your_Resource_Group",
    SqlServerName = "Your_SQL_Server_Name",
    DatabaseName = "Your_Database_Name"
};

Usage

Scaling Azure Web App

To scale an Azure Web App, follow these steps:

  1. Create an instance of WebApplicationService using the provided credentials and resource information, same applies for the SQL Server!
var webAppServiceScaler = new WebApplicationService(credentials, webAppResources);

webAppServiceScaler.CreateAzureClient();

IWebApp webApp = webAppServiceScaler.GetWebApp();


//Provide how many scaled instances desired with this pricing tier!

webAppServiceScaler.Scale(PricingTier.StandardS1, 2);

Scaling Azure SQL Server

To scale an Azure SQL Server, follow these steps:

  1. Create an instance of SQLDatabaseService using the provided credentials and resource information:
// Update these values with your actual Azure application credentials
var credentials = new AzureApplicationCredentials()
{
    ClientId = "Your_Client_Id",
    ClientSecret = "Your_Client_Secret",
    TenantId = "Your_Tenant_Id",
    SubscriptionId = "Your_Subscription_Id"
};

// Update these values with your actual Azure resource information for the SQL Server
var sqlResources = new SQLCredentials()
{
    ResourceGroupName = "Your_Resource_Group",
    SqlServerName = "Your_SQL_Server_Name",
    DatabaseName = "Your_Database_Name"
};

var sqlDatabaseService = new SQLDatabaseService(credentials, sqlResources);

sqlDatabaseService.CreateAzureClient();

var desiredPlan = ServiceObjectiveName.S1;

ISqlDatabase updatedSqlDatabase = sqlDatabaseService.Scale(desiredPlan);

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.5 935 7/25/2023
1.0.1 163 7/25/2023
1.0.0 172 7/25/2023