How to get deployment credentials from WebApp ARM script?

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

When deploying WebApp by using of ARM script, the Resource Provider will create so called deployment credentials under the hub.

These credentials are usually downloaded from the Azure Portal.

image

After download you will get something like this.

<publishData>
    <publishProfile profileName="CSharpWebJobs - Web Deploy"
        publishMethod="MSDeploy"
        publishUrl="web.scm.azurewebsites.net:443"
        msdeploySite="web"
       userName="$***"
        userPWD="****"
        destinationAppUrl="http://csharpwebjobs.azurewebsites.net"
        SQLServerDBConnectionString=""
        mySQLDBConnectionString=""
        hostingProviderForumLink=""
        controlPanelLink=http://windows.azure.com


</publishData>

Please notice there userName and password. These credentials are automatically created. Please do not be confused with FTP credentials, which has to be explicitly created.

But, what if you are deploying your application programmatically with ARM script and at the end of deployment you have to programmatically deploy a WebJob in the WebApp?

To make this possible, you will have to get deployment credentials programmatically. This can be done directlly in ARM script during deployment of WebApp. Following ARM snippet shows how to define “outputs”, which gets out credentials.

"outputs": {

    "username": {

      "value": "[list(resourceId('Microsoft.Web/sites/config', variables('webSiteName'), 'publishingcredentials'), '2016-08-01').properties.publishingUserName]",

      "type": "string"

    },

    "password": {

      "value": "[list(resourceId('Microsoft.Web/sites/config', variables('webSiteName'), 'publishingcredentials'), '2016-08-01').properties.publishingPassword]",

      "type": "string"

    }


Posted Mar 31 2017, 10:29 AM by Damir Dobric

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
developers.de is a .Net Community Blog powered by daenet GmbH.