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

Provision sample for ASP.NET on azure_rm_app_service #407

Merged

Conversation

pjmolina
Copy link
Contributor

@pjmolina pjmolina commented Oct 9, 2017

Hi!
Added an example for provisioning an ASP.NET website into Azure App Service with terraform.

tombuildsstuff added a commit that referenced this pull request Nov 4, 2017
… as highlighted in #407

```
$ acctests azurerm TestAzureRMAppServicePlanName_validation
=== RUN   TestAzureRMAppServicePlanName_validation
--- PASS: TestAzureRMAppServicePlanName_validation (0.00s)
PASS
ok      github.com/terraform-providers/terraform-provider-azurerm/azurerm    0.029s

$ acctests azurerm TestAzureRMAppServiceName_validation
=== RUN   TestAzureRMAppServiceName_validation
--- PASS: TestAzureRMAppServiceName_validation (0.00s)
PASS
ok      github.com/terraform-providers/terraform-provider-azurerm/azurerm    0.019s
```
tombuildsstuff added a commit that referenced this pull request Nov 4, 2017
… as highlighted in #407

```
$ acctests azurerm TestAzureRMAppServicePlanName_validation
=== RUN   TestAzureRMAppServicePlanName_validation
--- PASS: TestAzureRMAppServicePlanName_validation (0.00s)
PASS
ok      github.com/terraform-providers/terraform-provider-azurerm/azurerm    0.029s

$ acctests azurerm TestAzureRMAppServiceName_validation
=== RUN   TestAzureRMAppServiceName_validation
--- PASS: TestAzureRMAppServiceName_validation (0.00s)
PASS
ok      github.com/terraform-providers/terraform-provider-azurerm/azurerm    0.019s
```
Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

Hey @pjmolina

Thanks for this PR - apologies for the delay in reviewing this! I've taken a look at this and left some comments in-line but this is off to a good start :)

Thanks!

}
}

# underscores not supported as app_service name -> if not: you will receive error 400
Copy link
Contributor

Choose a reason for hiding this comment

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

}

output "adminUrl" {
value = "https://${azurerm_app_service.common_service.name}.scm.azurewebsites.net"
Copy link
Contributor

Choose a reason for hiding this comment

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

note: these two values (serviceUrl and adminUrl) assume we're running in Azure Public (and not Germany/Government/China etc) - I took a quick look into if we could expose these variables so this example could also work in those environments, but unfortunately those values aren't immediately available - so this should be fine :)

}

resource "azurerm_resource_group" "g1" {
name = "{$var.groupName}"
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be ${var.groupName} (I'll push a commit to fix this)

client_id = "${var.client_id}"
client_secret = "${var.client_secret}"
tenant_id = "${var.tenant_id}"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

we tend to leave this commented out in case people opt to use Azure CLI auth (I'll push a commit to amend this)

@@ -0,0 +1,45 @@
variable "groupName" {
Copy link
Contributor

Choose a reason for hiding this comment

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

minor I might suggest renaming this resource_group_name to be clearer (and underscores for consistency) - (I'll push a commit for this)

default = "westeurope"
}

variable "webName" {
Copy link
Contributor

Choose a reason for hiding this comment

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

(same here) webName -> web_name (I'll push a commit for this)

# }

provisioner "local-exec" {
command = "curl -k -u ${var.deploy_user}:${var.deploy_pass} -X PUT --data-binary @${var.deployZipFile} https://${azurerm_app_service.common_service.name}.scm.azurewebsites.net/api/zip/site/wwwroot/"
Copy link
Contributor

Choose a reason for hiding this comment

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

out of interest, how are these values set? From memory these need to be set either in the portal/through the CLI before use, given Terraform currently doesn't support them and they're disabled by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review Tom.
Yes, I didn't find a way yet to setup such deploy Azure credentials in a CLI/programmatic way.
As far as I know, them should be setup once in the Azure Portal per Azure Account.
Probably MS Azure guys can help with it.

Copy link
Contributor

Choose a reason for hiding this comment

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

hey @pjmolina

Apologies for the delayed response here!

In order for us to be able to ship this PR (without making the user having to navigate to the portal to enter the credentials) - I've pushed a commit to remove the publishing credentials snippet from the sample for the moment. Once support for configuring the App Service Publish Credentials is available through Terraform we can look into adding this back in - however for the moment this feels like the best compromise to ship this.

I've also opened #612 which exports the Default Hostname for the App Service - such that we can determine what it is (since azurewebsites.net is only valid for Azure Public and not China/Germany/Government) - so once that's merged this PR should be good to merge :)

Hope that makes sense and you don't mind?

Thanks!

Copy link
Contributor Author

@pjmolina pjmolina Dec 11, 2017

Choose a reason for hiding this comment

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

Ok @tombuildsstuff I see your point.
A pity to loose the provisioner part because it is the main point of the example: provisioning the app, not just creating the bucket for it. It is true Microsoft should enable a way to setup the deployment credentials programmatically, without needing to enter manually in the portal.

Copy link
Contributor

Choose a reason for hiding this comment

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

@pjmolina totally get that - we'll look to add it back in to the example once support for configuring the credentials is added to the Provider :)

This removes support for Publishing, since the SCM URL's aren't consistent across Sovereign Clouds (China/Germany/Govt etc)
Switches to using the new `default_site_hostname` field introduced in hashicorp#612 rather than assuming what it is
Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

LGTM thanks for this - we'll merge this once #612 has been merged in 👍

@tombuildsstuff tombuildsstuff merged commit a3b207f into hashicorp:master Dec 8, 2017
@ghost
Copy link

ghost commented Apr 1, 2020

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 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants