Skip to content

Commit 9c882aa

Browse files
[App Service] az functionapp create, az functionapp deployment config set: Add Flex Consumption Registry deployment storage support
Add --deployment-image, --deployment-image-auth-type, --deployment-image-identity, --deployment-image-username-setting, --deployment-image-password-setting and --deployment-image-server-url so Flex Consumption apps can run a container image from functionAppConfig.deployment.storage of type Registry (Microsoft.Web 2025-05-01). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent da4c054 commit 9c882aa

7 files changed

Lines changed: 630 additions & 28 deletions

File tree

‎src/azure-cli/azure/cli/command_modules/appservice/_constants.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ def __init__(self):
147147

148148
DEPLOYMENT_STORAGE_AUTH_TYPES = ['SystemAssignedIdentity', 'UserAssignedIdentity', 'StorageAccountConnectionString']
149149

150+
FLEX_REGISTRY_AUTH_TYPES = ['Anonymous', 'SystemAssignedIdentity', 'UserAssignedIdentity', 'Basic']
151+
152+
FLEX_REGISTRY_API_VERSION = '2025-05-01'
153+
154+
# Registry apps have no runtime stack to supply scale defaults, so use the Flex Consumption stack defaults.
155+
FLEX_DEFAULT_MAXIMUM_INSTANCE_COUNT = 100
156+
FLEX_DEFAULT_INSTANCE_MEMORY_MB = 2048
157+
150158
UPDATE_STRATEGY_TYPES = ['Recreate', 'RollingUpdate']
151159

152160
STORAGE_BLOB_DATA_CONTRIBUTOR_ROLE_ID = 'ba92f5b4-2d11-453d-a403-e96b0029c9fe'

‎src/azure-cli/azure/cli/command_modules/appservice/_help.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,11 +596,27 @@
596596
helps['functionapp deployment config set'] = """
597597
type: command
598598
short-summary: Update an existing function app's deployment configuration.
599+
long-summary: >
600+
Use the --deployment-storage-* arguments for blob container deployment storage, or the --deployment-image
601+
arguments for a Flex Consumption app that runs a container image (Registry deployment storage). Registry settings
602+
are stored in the app's functionAppConfig and are separate from the legacy Linux container settings managed by
603+
`az functionapp config container`. Switching to Registry removes the
604+
functionAppConfig runtime. The service accepting the configuration doesn't prove that the registry is reachable,
605+
that access is authorized, or that deployment succeeds. The CLI doesn't track tags; setting the same tag again
606+
doesn't pull a newer image.
599607
examples:
600608
- name: Set the function app's deployment storage.
601609
text: az functionapp deployment config set --name MyFunctionApp --resource-group MyResourceGroup --deployment-storage-name MyStorageAccount --deployment-storage-container-name MyStorageContainer
602610
- name: Set the function app's deployment storage authentication method.
603611
text: az functionapp deployment config set --name MyFunctionApp --resource-group MyResourceGroup --deployment-storage-auth-type userAssignedIdentity --deployment-storage-auth-value myAssignedId
612+
- name: Run a public container image (Anonymous authentication).
613+
text: az functionapp deployment config set --name MyFunctionApp --resource-group MyResourceGroup --deployment-image mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0 --deployment-image-auth-type Anonymous
614+
- name: Pull a container image by digest with the app's system-assigned identity.
615+
text: az functionapp deployment config set --name MyFunctionApp --resource-group MyResourceGroup --deployment-image myregistry.azurecr.io/myimage@sha256:<digest> --deployment-image-auth-type SystemAssignedIdentity
616+
- name: Pull the container image with a user-assigned identity.
617+
text: az functionapp deployment config set --name MyFunctionApp --resource-group MyResourceGroup --deployment-image-auth-type UserAssignedIdentity --deployment-image-identity /subscriptions/<subscription-id>/resourceGroups/MyResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/MyIdentity
618+
- name: Pull the container image with a username and password stored in app settings (Basic authentication).
619+
text: az functionapp deployment config set --name MyFunctionApp --resource-group MyResourceGroup --deployment-image-auth-type Basic --deployment-image-username-setting REGISTRY_USERNAME --deployment-image-password-setting REGISTRY_PASSWORD --deployment-image-server-url https://myregistry.azurecr.io
604620
"""
605621

606622
helps['functionapp deployment config show'] = """
@@ -780,6 +796,9 @@
780796
- name: Create a flex consumption function app. See https://aka.ms/flex-http-concurrency for more information on default http concurrency values.
781797
text: >
782798
az functionapp create -g MyResourceGroup --name MyUniqueAppName -s MyStorageAccount --flexconsumption-location northeurope --runtime java --instance-memory 2048
799+
- name: Create a flex consumption function app that runs a container image from Azure Container Registry, pulled with the app's system-assigned identity. The service accepting the configuration doesn't prove that the image can be pulled.
800+
text: >
801+
az functionapp create -g MyResourceGroup --name MyUniqueAppName -s MyStorageAccount --flexconsumption-location northeurope --deployment-image myregistry.azurecr.io/myimage:v1 --deployment-image-auth-type SystemAssignedIdentity --assign-identity [system] --role AcrPull --scope /subscriptions/<subscription-id>/resourceGroups/MyResourceGroup/providers/Microsoft.ContainerRegistry/registries/myregistry
783802
"""
784803

785804
helps['functionapp delete'] = """

‎src/azure-cli/azure/cli/command_modules/appservice/_params.py‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
from ._completers import get_hostname_completion_list
2121
from ._constants import (FUNCTIONS_VERSIONS, LOGICAPPS_NODE_RUNTIME_VERSIONS, WINDOWS_OS_NAME, LINUX_OS_NAME,
22-
DEPLOYMENT_STORAGE_AUTH_TYPES, UPDATE_STRATEGY_TYPES, ISOLATED_V4_SKUS)
22+
DEPLOYMENT_STORAGE_AUTH_TYPES, UPDATE_STRATEGY_TYPES, ISOLATED_V4_SKUS,
23+
FLEX_REGISTRY_AUTH_TYPES)
2324

2425
from ._validators import (validate_timeout_value, validate_site_create, validate_asp_create,
2526
validate_ase_create, validate_ip_address,
@@ -1230,6 +1231,23 @@ def load_arguments(self, _):
12301231
"this should be the user assigned identity resource id. For the storage account connection string authentication type, this should be the name of the app setting that will contain the storage account connection "
12311232
"string. For the system assigned managed-identity authentication type, this parameter is not applicable and should be left empty.")
12321233

1234+
for scope in ['functionapp create', 'functionapp deployment config set']:
1235+
with self.argument_context(scope, arg_group='Flex Registry Deployment') as c:
1236+
c.argument('deployment_image', options_list=['--deployment-image'],
1237+
help="Container image for a Flex Consumption app, e.g. `myregistry.azurecr.io/myimage:v1` or `myregistry.azurecr.io/myimage@sha256:<digest>`. "
1238+
"Saved unchanged as the app's Registry deployment storage; the CLI doesn't validate, resolve, or pull it. Unrelated to legacy Linux container settings.")
1239+
c.argument('deployment_image_auth_type', options_list=['--deployment-image-auth-type', '--diat'], arg_type=get_enum_type(FLEX_REGISTRY_AUTH_TYPES),
1240+
help="How the platform authenticates to the registry: Anonymous (public image), SystemAssignedIdentity, UserAssignedIdentity (requires --deployment-image-identity), "
1241+
"or Basic (requires --deployment-image-username-setting and --deployment-image-password-setting). The CLI doesn't assign identities or grant registry access.")
1242+
c.argument('deployment_image_identity', options_list=['--deployment-image-identity', '--dii'],
1243+
help="Resource ID of the user-assigned managed identity used to pull the image. Only valid with UserAssignedIdentity. Saved as provided; the CLI doesn't create, look up, or assign it.")
1244+
c.argument('deployment_image_username_setting', options_list=['--deployment-image-username-setting', '--dius'],
1245+
help="Name of the app setting that stores the registry username. Only valid with Basic.")
1246+
c.argument('deployment_image_password_setting', options_list=['--deployment-image-password-setting', '--dips'],
1247+
help="Name of the app setting that stores the registry password. Only valid with Basic. Pass the app setting name, not the password.")
1248+
c.argument('deployment_image_server_url', options_list=['--deployment-image-server-url', '--diurl'],
1249+
help="Registry server URL for Basic authentication, e.g. `https://myregistry.azurecr.io`. Optional; only valid with Basic.")
1250+
12331251
with self.argument_context('functionapp cors credentials') as c:
12341252
c.argument('enable', help='enable/disable access-control-allow-credentials', arg_type=get_three_state_flag())
12351253

0 commit comments

Comments
 (0)