简体   繁体   中英

Create a server farm (aka App Service Plan) from the command line

We are creating an Azure Web App using the command line interface. How do we create a server farm from the CLI? This is what we have already done.

azure login
azure group create MyGroup "West US"
azure webapp create -g MyGroup -n MyApp -l "West US"

The error is:

parameters.webSite.properties.serverFarm cannot be null.

How do we create a server farm from the CLI? Here are some things we have tried.

azure resource create -g MyGroup -n MyFarm 
    -r "Microsoft.Web/ServerFarms" -l "West US" -o "2015-08-01" 
    -p "{ `"SKU`": `"`" }"

We have not been able to determine how to set the -p value with an appropriate JSON object. Azure complains about unexpected characters. None of these work.

-p "{ sku: "" }"          // Unexpected token s
-p "{ 'sku': "" }"        // Unexpected token '
-p "{ \'sku\' : \'\' }"   // uUnexpected token \
-p "{ `'sku`' : `'`' }"   // uUnexpected token '
-p "{ `"sku`" : `"`" }"   // Unexpected token s
-p "{\"sku\":{\"tier\": \"Standard\"}}"    // SKU cannot be null.

-p is supposed to be "a JSON-formatted string containing properties". What do they mean by that?

Try this if you intend to use api-version 2015-08-01

azure resource create MyGroup MyFarm "Microsoft.Web/ServerFarms" 
  -l "West US" -o "2015-08-01" 
  -p "{\"sku\":{\"tier\": \"Standard\", \"name\": \"S1\"}, \"properties\": {\"numberOfWorkers\": 1, \"workerSize\": 0}"

This works with -apiVersion 2015-06-01 though I haven't figured out the schema change for 2015-08-01 .

azure resource create MyGroup MyFarm "Microsoft.Web/ServerFarms" 
  -l "West US" -o "2015-06-01" 
  -p "{\"sku\":{\"tier\": \"Standard\"},\"numberOfWorkers\":1,\"workerSize\": \"Small\"}"

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