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

New Resource azurerm_function_app_on_container #27249

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

xiaxyi
Copy link
Contributor

@xiaxyi xiaxyi commented Aug 30, 2024

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for PR followers and do not help prioritize for review

Description

Support the new resource - hosting azure function app in container app environment.

PR Checklist

  • I have followed the guidelines in our Contributing Documentation.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • I have checked if my changes close any open issues. If so please include appropriate closing keywords below.
  • I have updated/added Documentation as required written in a helpful and kind way to assist users that may be unfamiliar with the resource / data source.
  • I have used a meaningful PR title to help maintainers and other users understand this change and help prevent duplicate work.
    For example: “resource_name_here - description of change e.g. adding property new_property_name_here

Changes to existing Resource / Data Source

  • I have added an explanation of what my changes do and why I'd like you to include them (This may be covered by linking to an issue above, but may benefit from additional explanation).
  • I have written new tests for my resource or datasource changes & updated any relevent documentation.
  • I have successfully run tests with my changes locally. If not, please provide details on testing challenges that prevented you running the tests.
  • (For changes that include a state migration only). I have manually tested the migration path between relevant versions of the provider.

Testing

  • My submission includes Test coverage as described in the Contribution Guide and the tests pass. (if this is not possible for any reason, please include details of why you did or could not add test coverage)

--- PASS: TestAccLinuxFunctionAppOnContainer_completePublicRegistry (1043.98s)
PASS
ok github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice 1067.438s

--- PASS: TestAccLinuxFunctionAppOnContainer_basicPublicRegistry (1093.35s)
PASS
ok github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice 1116.159s
--- PASS: TestAccLinuxFunctionAppOnContainer_storageUsesMSI (1073.56s)
PASS
ok github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice 1082.432s

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

  • azurerm_resource - support for the thing1 property [GH-00000]

This is a (please select all that apply):

  • Bug Fix
  • New Feature (ie adding a service, resource, or data source)
  • Enhancement
  • Breaking Change

Related Issue(s)

#23470

Note

If this PR changes meaningfully during the course of review please update the title and description as required.

Copy link
Contributor

@ms-zhenhua ms-zhenhua left a comment

Choose a reason for hiding this comment

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

Hi @xiaxyi ,

Thanks for this PR - I've taken a look through and left some comments inline. If we can fix those up, this should be good to go 👍


"resource_group_name": commonschema.ResourceGroupName(),

"container_app_environment_id": {
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we use "container_app_environment_id": commonschema.ResourceIDReferenceForceNew(managedenvironments.ManagedEnvironmentID{}), ?


"registry": helpers.RegistrySchemaLinuxFunctionAppOnContainer(),

"container_image": {
Copy link
Contributor

Choose a reason for hiding this comment

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

please put Required fields ahead of Optional ones

Description: "The Connection String for linking the Linux Function App to Application Insights.",
},

"app_scale_limit": {
Copy link
Contributor

Choose a reason for hiding this comment

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

please add ValidateFunc to set the value range

Description: "The number of workers this function app can scale out to. Only applicable to apps on the Consumption and Premium plan.",
},

"elastic_instance_minimum": {
Copy link
Contributor

Choose a reason for hiding this comment

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

please add ValidateFunc to set the value range

storageString = fmt.Sprintf(helpers.StorageStringFmtKV, linuxFunctionAppOnContainer.StorageKeyVaultSecretID)
}

siteConfig := helpers.ExpandSiteConfigLinuxFunctionAppOnContainer(linuxFunctionAppOnContainer.SiteConfig, nil, metadata, linuxFunctionAppOnContainer.Registries[0], linuxFunctionAppOnContainer.FunctionExtensionsVersion, storageString)
Copy link
Contributor

Choose a reason for hiding this comment

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

what if len(linuxFunctionAppOnContainer.Registries) == 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the required field


* `functions_extension_version` - (Optional) The runtime version associated with the Function App. Defaults to `~4`.

* `key_vault_reference_identity_id` - (Optional) The User Assigned Identity ID used for accessing KeyVault secrets. The identity must be assigned to the application in the `identity` block. [For more information see - Access vaults with a user-assigned identity](https://docs.microsoft.com/azure/app-service/app-service-key-vault-references#access-vaults-with-a-user-assigned-identity)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* `key_vault_reference_identity_id` - (Optional) The User Assigned Identity ID used for accessing KeyVault secrets. The identity must be assigned to the application in the `identity` block. [For more information see - Access vaults with a user-assigned identity](https://docs.microsoft.com/azure/app-service/app-service-key-vault-references#access-vaults-with-a-user-assigned-identity)
* `key_vault_reference_identity_id` - (Optional) The User Assigned Identity ID used for accessing KeyVault secrets. The identity must be assigned to the application in the `identity` block. See [Access vaults with a user-assigned identity](https://docs.microsoft.com/azure/app-service/app-service-key-vault-references#access-vaults-with-a-user-assigned-identity) for more information.


* `key_vault_reference_identity_id` - (Optional) The User Assigned Identity ID used for accessing KeyVault secrets. The identity must be assigned to the application in the `identity` block. [For more information see - Access vaults with a user-assigned identity](https://docs.microsoft.com/azure/app-service/app-service-key-vault-references#access-vaults-with-a-user-assigned-identity)

* `storage_account_access_key` - (Optional) The access key which will be used to access the backend storage account for the Function App. Conflicts with `storage_uses_managed_identity`.
Copy link
Contributor

Choose a reason for hiding this comment

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

could you please put Conflicts with ... into **NOTE** ?


* `application_insights_key` - (Optional) The Instrumentation Key for connecting the Containerized Linux Function App to Application Insights.

* `app_scale_limit` - (Optional) The number of workers this function app can scale out to. Only applicable to apps on the Consumption and Premium plan.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* `app_scale_limit` - (Optional) The number of workers this function app can scale out to. Only applicable to apps on the Consumption and Premium plan.
* `app_scale_limit` - (Optional) The number of workers this function app can scale out to, which is only applicable to apps on the Consumption and Premium plan. Defaults to `10`


registry {
registry_server_url = "mcr.microsoft.com"
registry_username = ""
Copy link
Contributor

Choose a reason for hiding this comment

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

could you also test registry_username and registry_password with values?


type LinuxFunctionAppOnContainerResource struct{}

func TestAccLinuxFunctionAppOnContainer_basicDocker(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

seems storage_key_vault_secret_id, site_config.application_insights_key, site_config.elastic_instance_minimum ,site_config.linux_fx_version, identity are not test. Could you add these testcases?

Copy link

github-actions bot commented Oct 7, 2024

This PR is being labeled as "stale" because it has not been updated for 30 or more days.

If this PR is still valid, please remove the "stale" label. If this PR is blocked, please add it to the "Blocked" milestone.

If you need some help completing this PR, please leave a comment letting us know. Thank you!

@github-actions github-actions bot added the stale label Oct 7, 2024
@xiaxyi xiaxyi marked this pull request as ready for review October 17, 2024 09:53
@xiaxyi
Copy link
Contributor Author

xiaxyi commented Oct 17, 2024

Thanks @ms-zhenhua for the review, I updated the code per comment, also made the PR to "ready to review" status as the api issue was fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants