diff --git a/azurerm/resource_arm_app_service_slot.go b/azurerm/resource_arm_app_service_slot.go index 829b0a55daad..659a1905aed8 100644 --- a/azurerm/resource_arm_app_service_slot.go +++ b/azurerm/resource_arm_app_service_slot.go @@ -138,6 +138,25 @@ func resourceArmAppServiceSlot() *schema.Resource { "tags": tagsSchema(), + "site_credential": { + Type: schema.TypeList, + Computed: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "username": { + Type: schema.TypeString, + Computed: true, + }, + "password": { + Type: schema.TypeString, + Computed: true, + Sensitive: true, + }, + }, + }, + }, + "default_site_hostname": { Type: schema.TypeString, Computed: true, @@ -370,6 +389,19 @@ func resourceArmAppServiceSlotRead(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error making Read request on AzureRM App Service Slot ConnectionStrings %q/%q: %+v", appServiceName, slot, err) } + siteCredFuture, err := client.ListPublishingCredentialsSlot(ctx, resGroup, appServiceName, slot) + if err != nil { + return err + } + err = siteCredFuture.WaitForCompletionRef(ctx, client.Client) + if err != nil { + return err + } + siteCredResp, err := siteCredFuture.Result(client) + if err != nil { + return fmt.Errorf("Error making Read request on AzureRM App Service Slot Site Credential %q/%q: %+v", appServiceName, slot, err) + } + d.Set("name", slot) d.Set("app_service_name", appServiceName) d.Set("resource_group_name", resGroup) @@ -397,6 +429,11 @@ func resourceArmAppServiceSlotRead(d *schema.ResourceData, meta interface{}) err return err } + siteCred := flattenAppServiceSiteCredential(siteCredResp.UserProperties) + if err := d.Set("site_credential", siteCred); err != nil { + return err + } + identity := flattenAzureRmAppServiceMachineIdentity(resp.Identity) if err := d.Set("identity", identity); err != nil { return err diff --git a/website/docs/r/app_service_slot.html.markdown b/website/docs/r/app_service_slot.html.markdown index 9d0ee979e65a..0ed68b25a02a 100644 --- a/website/docs/r/app_service_slot.html.markdown +++ b/website/docs/r/app_service_slot.html.markdown @@ -260,6 +260,15 @@ The following attributes are exported: * `default_site_hostname` - The Default Hostname associated with the App Service Slot - such as `mysite.azurewebsites.net` +* `site_credential` - A `site_credential` block as defined below, which contains the site-level credentials used to publish to this App Service. + +--- + +`site_credential` exports the following: + +* `username` - The username which can be used to publish to this App Service +* `password` - The password associated with the username, which can be used to publish to this App Service. + ## Import App Service Slots can be imported using the `resource id`, e.g.