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 staticwebapp functions link: Add new parameter --environment-name to support setting the environment name of static site #23894

Merged
merged 9 commits into from
Jan 5, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,7 @@ def load_arguments(self, _):
c.argument('sku', arg_type=static_web_app_sku_arg_type)
with self.argument_context('staticwebapp functions link') as c:
c.argument('function_resource_id', help="Resource ID of the functionapp to link. Can be retrieved with 'az functionapp --query id'")
c.argument('environment_name', options_list=['--environment-name'], help="Name of the environment of static site")
zhoxing-ms marked this conversation as resolved.
Show resolved Hide resolved
c.argument('force', help="Force the function link even if the function is already linked to a static webapp. May be needed if the function was previously linked to a static webapp.")

with self.argument_context('staticwebapp enterprise-edge') as c:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,14 @@ def reset_staticsite_api_key(cmd, name, resource_group_name=None):
reset_properties_envelope=reset_envelope)


def link_user_function(cmd, name, resource_group_name, function_resource_id, force=False):
def link_user_function(
cmd,
name,
resource_group_name,
function_resource_id,
environment_name: str = "default",
force=False,
):
from azure.mgmt.web.models import StaticSiteUserProvidedFunctionAppARMResource

if force:
Expand All @@ -581,6 +588,7 @@ def link_user_function(cmd, name, resource_group_name, function_resource_id, for
name=name,
resource_group_name=resource_group_name,
function_app_name=function_name,
environment_name=environment_name,
static_site_user_provided_function_envelope=function,
is_forced=force)

StrawnSC marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ def test_functions_link(self, *args, **kwargs):
functionapp_resource_id = "/subscriptions/sub/resourceGroups/{}/providers/Microsoft.Web/sites/{}".format(
self.rg1, functionapp_name
)
link_user_function(self.mock_cmd, self.name1, self.rg1, functionapp_resource_id)
link_user_function(self.mock_cmd, self.name1, self.rg1, functionapp_resource_id, self.environment1)

self.staticapp_client.begin_register_user_provided_function_app_with_static_site.assert_called_once()

Expand Down