简体   繁体   中英

Create a REST API scaling SQL Server

I want to create a REST API which scales the maximum size of my Azure SQL Server Database and include that API in my Azure Function

I tried by the normal requests like PUT,PATCH but everytime it shows that Authorization Header is missing. How to include the Authorization header in the Request part??

If you are not must to use REST API to scale the Azure SQL database, you can refenence this document: Scale your Azure SQL Database with Azure Functions :

To automatically scale the database up from Azure Functions, using the following code:

private static async Task ScaleDatabaseUp()
{
            var constring = Environment.GetEnvironmentVariable("SQL_DB");
            var query = string.Format(@"
ALTER DATABASE <DATABASENAME>
    MODIFY (SERVICE_OBJECTIVE = 'PRS1'); --PRS1");
            using (SqlConnection conn = new SqlConnection(constring))
            {
                SqlCommand cmd = new SqlCommand(query, conn);
                cmd.Connection.Open();
                await cmd.ExecuteNonQueryAsync();

            }           
}

You have to replace with the name of your database and potentially also the service objective (SKU).

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM