Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[App Service] az functionapp create: Create consumption plan when creating the function app #30612

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4924,6 +4924,11 @@ def create_functionapp(cmd, resource_group_name, name, storage_account, plan=Non
functionapp_def.kind = 'functionapp'
# if os_type is None, the os type is windows
is_linux = bool(os_type and os_type.lower() == LINUX_OS_NAME)
plan_name = generatePlanName(resource_group_name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the reason why the recording tests failed. A new random plan name will be generated when each time this function is run. Thus, when tests are run under recording mode, the plan name is generated again and different from what in the recoding file.

def generatePlanName(resource_group_name):
suffix = "-" + str(uuid.uuid4())[:4]
alphanumeric_resource_group_name = re.sub(r"[^a-zA-Z0-9]", '', resource_group_name)
first_part = 'ASP-{}'.format(alphanumeric_resource_group_name)[:35]
return '{}{}'.format(first_part, suffix)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @yanzhudd We actually do intend to create a new plan resource with a new name on behalf of the customer. Does this mean we should just make the tests run live? Or what would you require for this PR to be merged?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, please mark the related tests as live only, and remove the corresponding recording files as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Thank you @yanzhudd. The PR is ready to be merged. Can you please review/merge it?

poller = create_functionapp_app_service_plan(cmd, resource_group_name, plan_name, is_linux,
'Y1', location=consumption_plan_location)
plan_info = LongRunningOperation(cmd.cli_ctx)(poller)
functionapp_def.server_farm_id = plan_info.id

elif plan: # apps with SKU based plan
if is_valid_resource_id(plan):
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
interactions:
- request:
body: '{"location": "southcentralus", "sku": {"name": "Y1", "tier": "Dynamic"},
"properties": {"perSiteScaling": false, "reserved": true, "isXenon": false,
"zoneRedundant": false}}'
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
CommandName:
- functionapp plan create
Connection:
- keep-alive
Content-Length:
- '173'
Content-Type:
- application/json
ParameterSetName:
- -g -n --sku --is-linux --location
User-Agent:
- AZURECLI/2.68.0 azsdk-python-core/1.31.0 Python/3.11.9 (Windows-10-10.0.26100-SP0)
method: PUT
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Web/serverfarms/functionappplan000003?api-version=2023-01-01
response:
body:
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Web/serverfarms/functionappplan000003","name":"functionappplan000003","type":"Microsoft.Web/serverfarms","kind":"functionapp","location":"southcentralus","properties":{"serverFarmId":85213,"name":"functionappplan000003","sku":{"name":"Y1","tier":"Dynamic","size":"Y1","family":"Y","capacity":0},"workerSize":"Default","workerSizeId":0,"workerTierName":null,"numberOfWorkers":0,"currentWorkerSize":"Default","currentWorkerSizeId":0,"currentNumberOfWorkers":0,"status":"Ready","webSpace":"clitest.rg000001-SouthCentralUSwebspace-Linux","subscription":"dbf67cc6-6c57-44b8-97fc-4356f0d555b3","adminSiteName":null,"hostingEnvironment":null,"hostingEnvironmentProfile":null,"maximumNumberOfWorkers":0,"planName":"VirtualDedicatedPlan","adminRuntimeSiteName":null,"computeMode":"Dynamic","siteMode":null,"geoRegion":"South
Central US","perSiteScaling":false,"elasticScaleEnabled":false,"maximumElasticWorkerCount":1,"numberOfSites":0,"hostingEnvironmentId":null,"isSpot":false,"spotExpirationTime":null,"freeOfferExpirationTime":null,"tags":null,"kind":"functionapp","resourceGroup":"clitest.rg000001","reserved":true,"isXenon":false,"hyperV":false,"mdmId":"waws-prod-sn1-147_85213","targetWorkerCount":0,"targetWorkerSizeId":0,"provisioningState":"Succeeded","webSiteId":null,"existingServerFarmIds":null,"kubeEnvironmentProfile":null,"zoneRedundant":false,"migrateToVMSS":null,"vnetConnectionsUsed":null,"vnetConnectionsMax":null,"createdTime":"2025-01-23T16:22:08.1633333"},"sku":{"name":"Y1","tier":"Dynamic","size":"Y1","family":"Y","capacity":0}}'
headers:
cache-control:
- no-cache
content-length:
- '1656'
content-type:
- application/json
date:
- Thu, 23 Jan 2025 16:22:08 GMT
expires:
- '-1'
pragma:
- no-cache
strict-transport-security:
- max-age=31536000; includeSubDomains
x-aspnet-version:
- 4.0.30319
x-cache:
- CONFIG_NOCACHE
x-content-type-options:
- nosniff
x-ms-ratelimit-remaining-subscription-global-writes:
- '11999'
x-ms-ratelimit-remaining-subscription-writes:
- '799'
x-msedge-ref:
- 'Ref A: 3B28ED47C86D4658B4A097E140EE1DCB Ref B: CH1AA2020620039 Ref C: 2025-01-23T16:22:03Z'
x-powered-by:
- ASP.NET
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
CommandName:
- functionapp plan show
Connection:
- keep-alive
ParameterSetName:
- -g -n
User-Agent:
- AZURECLI/2.68.0 azsdk-python-core/1.31.0 Python/3.11.9 (Windows-10-10.0.26100-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Web/serverfarms/functionappplan000003?api-version=2023-01-01
response:
body:
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Web/serverfarms/functionappplan000003","name":"functionappplan000003","type":"Microsoft.Web/serverfarms","kind":"functionapp","location":"South
Central US","properties":{"serverFarmId":85213,"name":"functionappplan000003","workerSize":"Default","workerSizeId":0,"workerTierName":null,"numberOfWorkers":0,"currentWorkerSize":"Default","currentWorkerSizeId":0,"currentNumberOfWorkers":0,"status":"Ready","webSpace":"clitest.rg000001-SouthCentralUSwebspace-Linux","subscription":"dbf67cc6-6c57-44b8-97fc-4356f0d555b3","adminSiteName":null,"hostingEnvironment":null,"hostingEnvironmentProfile":null,"maximumNumberOfWorkers":0,"planName":"VirtualDedicatedPlan","adminRuntimeSiteName":null,"computeMode":"Dynamic","siteMode":null,"geoRegion":"South
Central US","perSiteScaling":false,"elasticScaleEnabled":false,"maximumElasticWorkerCount":1,"numberOfSites":0,"hostingEnvironmentId":null,"isSpot":false,"spotExpirationTime":null,"freeOfferExpirationTime":null,"tags":null,"kind":"functionapp","resourceGroup":"clitest.rg000001","reserved":true,"isXenon":false,"hyperV":false,"mdmId":"waws-prod-sn1-147_85213","targetWorkerCount":0,"targetWorkerSizeId":0,"provisioningState":"Succeeded","webSiteId":null,"existingServerFarmIds":null,"kubeEnvironmentProfile":null,"zoneRedundant":false,"migrateToVMSS":null,"vnetConnectionsUsed":0,"vnetConnectionsMax":2,"createdTime":"2025-01-23T16:22:08.1633333"},"sku":{"name":"Y1","tier":"Dynamic","size":"Y1","family":"Y","capacity":0}}'
headers:
cache-control:
- no-cache
content-length:
- '1577'
content-type:
- application/json
date:
- Thu, 23 Jan 2025 16:22:09 GMT
expires:
- '-1'
pragma:
- no-cache
strict-transport-security:
- max-age=31536000; includeSubDomains
x-aspnet-version:
- 4.0.30319
x-cache:
- CONFIG_NOCACHE
x-content-type-options:
- nosniff
x-ms-ratelimit-remaining-subscription-global-reads:
- '16499'
x-msedge-ref:
- 'Ref A: 60F481660DF0435EAC0EBB276B584A6F Ref B: CH1AA2020610033 Ref C: 2025-01-23T16:22:08Z'
x-powered-by:
- ASP.NET
status:
code: 200
message: OK
version: 1
Loading