I have an app_service that uses GitHub as SCM. The only two options available currently are None and LocalGit
https://github.com/terraform-providers/terraform-provider-azurerm/blob/master/azurerm/resource_arm_app_service.go#L153
However, it looks like the Azure SDK for Go now accepts many more SCM types.
I had a go at adding it in the validation, but I'm not entirely sure if I got it in the right place.
https://github.com/terraform-providers/terraform-provider-azurerm/pull/1103
@tombuildsstuff Is there any movement on this? I do not believe the upstream Microsoft label is applicable anymore
Any progress on this @tombuildsstuff ? I`ve been working around it by invoking AZ CLI and local-exec. But when I run plan or apply for the second time, it tries to modify the set value again.
Terraform will perform the following actions:
~ module.webapp_monitor.azurerm_app_service.default
site_config.0.scm_type: "ExternalHg" => "None"
And since scm_type is currently only expected to be None or LocalGit I`m not able to prevent Terraform to modify the setting.
expected site_config.0.scm_type to be one of [None LocalGit], got ExternalHg
I have written an example using the Go SDK for Azure, and using the web resource provider and the CreateOrUpdateSourceControl function to allow you to add an external Git repo URL to your Azure App Service and have it automatically built & deployed by Kudu (part of App Service)
I've tried looking at your source and adding this support in myself with a mind to submitting a PR, but I couldn't get past it telling me that "source_control" was ready only
We had to implement a workaround to add ExternalGit as scm_type while waiting. It is done by calling a powershell script with a null_resource. The script uses az account get-access-token to get a access token for Powershell and login-azurermaccount.
The reason for implementing it with PS and not CLI is basically the way we use webhooks with a privately hosted GitLab, it will always fail on initial deployment and PS lets us add "-ErrorAction SilentlyContinue", while CLI om the other hand does not allow to suppress output #18852 It is not pretty, but it works with both Web Apps, and Function Apps.
Param (
[Parameter(Mandatory = $true)]
[String]$webAppName,
[string]$appResourceGroupName,
[string]$repoUrl,
[string]$scmBranch
)
#Script uses Azure CLI Login credentials to forward access_token to Powershell
$subscriptions = (az account list -o json 2> $null | ConvertFrom-Json)
$subscriptionId= $subscriptions | Where-Object isDefault -like true
$accountId = $subscriptionId.user.name
$tenantId = $subscriptionId.tenantId
$adTokenRegistry = (az account get-access-token | ConvertFrom-Json)
$accessToken = $adtokenregistry.accessToken
Login-AzureRmAccount -AccessToken $accessToken -tenantid $tenantId -accountid $accountId
Write-Host "Getting App information"
$webApp = get-AzureRmResource -ResourceName $webAppName -ResourceType "Microsoft.Web/sites" -ApiVersion 2015-08-01 -ResourceGroupName $appResourceGroupName
$location = $webApp.Location
$webAppConfig = Get-AzureRmResource -ResourceName "$($webAppName)/web" -ResourceType "Microsoft.Web/sites/config" -ApiVersion 2015-08-01 -ResourceGroupName $appResourceGroupName
$currentScmType = $webAppConfig.Properties.scmType
if($currentScmType -ne $null -and $currentScmType -ne "None")
{
Write-Host "Already setup with scmType $currentScmType"
# App is already configured with source control, we cannot add again.
return
}
$propertiesObject = @{
repourl = "$repoUrl"
branch = "$scmBranch"
isManualIntegration = "true"
}
New-AzureRmResource -Properties $propertiesObject -ResourceName $webAppName/web -ResourceType Microsoft.Web/sites/SourceControls -ResourceGroupName $appResourceGroupName -ApiVersion 2015-08-01 -Force -ErrorAction SilentlyContinue
resource "null_resource" "scm_integration" { #using powershell 4-now, replacing when scm_type externalGit is avaliable in provider
count = "${var.enable_external_scm ? 1 : 0}"
provisioner "local-exec" {
command = "${path.module}/enable_scm.ps1 -webAppName ${var.appName} -appResourceGroupName ${var.resource_group_name} -scmBranch ${var.scm_branch} -repoUrl ${var.gitlab_base_url}/${var.gitlab_group}/${var.gitlab_project}"
interpreter = ["PowerShell", "-Command"]
}
}
With azurerm_app_service you have to ignore changes in source control, not required with azurerm_function_app
lifecycle {
ignore_changes = [
"site_config.0.scm_type"
]
hi @istairbn
This issue is currently blocked on https://github.com/Azure/azure-sdk-for-go/issues/1065 - I've requested an update there and we'll post an update here when we hear back.
Thanks!
Closing as a duplicate of #1801
Closed the wrong issue 🤦♀️
Thanks for your work on this.
Hopefully we can get away from our PowerShell code and move over to Terraform.
This will be extremely useful when complete. Looking forward for completion on it.
@bcornils
hi there, has this been added to the backlog as i too would like to use the app service and wordpress marketplace git repo
also when is CORS (allowedOrigins) support coming?
For all the people complaining about "VSTSRM", the problem is here: AzureRmWebAppDeploymentV4
And if you notice the condition above it, setting the SCM type to anything different from "None" should fix it as it should not be changed by that VSTS task anymore and thus working around this issue (I have successfully tested the solution as setting SCM type to LocalGIT doesn't matter in our case)
Fixed via #3019
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!
Most helpful comment
@tombuildsstuff Is there any movement on this? I do not believe the upstream Microsoft label is applicable anymore