Skip to content

Commit

Permalink
[functionapp] Added Azure Functions extension (#3926)
Browse files Browse the repository at this point in the history
* initial commit.

* Removed vendored sdks. Cleaned up extension. Added dependencies and tests.

* Added azure-functions-devops-build dependency

* Improved extension summary, added author details.

* Fixed style issue. Added entry to service_name.json.

* Fixed codeowners for extension.
  • Loading branch information
gzuber authored Oct 28, 2021
1 parent 7954d21 commit aeb3bf8
Show file tree
Hide file tree
Showing 18 changed files with 1,955 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,7 @@

/src/purview/ @kairu-ms @jsntcy

/src/functionapp/ @gzuber

/src/elastic/ @kairu-ms @jsntcy

8 changes: 8 additions & 0 deletions src/functionapp/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. :changelog:
Release History
===============

0.1.0
++++++
* Initial release.
5 changes: 5 additions & 0 deletions src/functionapp/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Microsoft Azure CLI 'functionapp' Extension
==========================================

This package is for the 'functionapp' extension.
i.e. 'az functionapp'
31 changes: 31 additions & 0 deletions src/functionapp/azext_functionapp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from azure.cli.core import AzCommandsLoader
from azext_functionapp._help import helps # pylint: disable=unused-import


class FunctionappCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azure.cli.core.profiles import ResourceType
functionapp_custom = CliCommandType(
operations_tmpl='azext_functionapp.custom#{}')
super().__init__(cli_ctx=cli_ctx,
custom_command_type=functionapp_custom,
resource_type=ResourceType.MGMT_APPSERVICE)

def load_command_table(self, args):
from azext_functionapp.commands import load_command_table
load_command_table(self, args)
return self.command_table

def load_arguments(self, command):
from azext_functionapp._params import load_arguments
load_arguments(self, command)


COMMAND_LOADER_CLS = FunctionappCommandsLoader
28 changes: 28 additions & 0 deletions src/functionapp/azext_functionapp/_help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# coding=utf-8
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from knack.help_files import helps # pylint: disable=unused-import


helps['functionapp devops-pipeline'] = """
type: group
short-summary: Azure Function specific integration with Azure DevOps. Please visit https://aka.ms/functions-azure-devops for more information.
"""

helps['functionapp devops-pipeline create'] = """
type: command
short-summary: Create an Azure DevOps pipeline for a function app.
examples:
- name: create an Azure Pipeline to a function app.
text: >
az functionapp devops-pipeline create --functionapp-name FunctionApp
- name: create an Azure Pipeline from a Github function app repository.
text: >
az functionapp devops-pipeline create --github-repository GithubOrganization/GithubRepository --github-pat GithubPersonalAccessToken
- name: create an Azure Pipeline with specific Azure DevOps organization and project
text: >
az functionapp devops-pipeline create --organization-name AzureDevOpsOrganization --project-name AzureDevOpsProject
"""
31 changes: 31 additions & 0 deletions src/functionapp/azext_functionapp/_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=line-too-long

from azure.cli.core.local_context import LocalContextAttribute, LocalContextAction
from azure.cli.core.commands.parameters import get_three_state_flag


def load_arguments(self, _):
# pylint: disable=line-too-long
# PARAMETER REGISTRATION

with self.argument_context('functionapp devops-pipeline') as c:
c.argument('functionapp_name', help="Name of the Azure function app that you want to use", required=False,
local_context_attribute=LocalContextAttribute(name='functionapp_name',
actions=[LocalContextAction.GET]))
c.argument('organization_name', help="Name of the Azure DevOps organization that you want to use",
required=False)
c.argument('project_name', help="Name of the Azure DevOps project that you want to use", required=False)
c.argument('repository_name', help="Name of the Azure DevOps repository that you want to use", required=False)
c.argument('overwrite_yaml', help="If you have an existing yaml, should it be overwritten?",
arg_type=get_three_state_flag(return_label=True), required=False)
c.argument('allow_force_push',
help="If Azure DevOps repository is not clean, should it overwrite remote content?",
arg_type=get_three_state_flag(return_label=True), required=False)
c.argument('github_pat', help="Github personal access token for creating pipeline from Github repository",
required=False)
c.argument('github_repository', help="Fullname of your Github repository (e.g. Azure/azure-cli)",
required=False)
4 changes: 4 additions & 0 deletions src/functionapp/azext_functionapp/azext_metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"azext.minCliCoreVersion": "2.0.46",
"azext.isPreview": true
}
Loading

0 comments on commit aeb3bf8

Please sign in to comment.