Convert Azure Publish Profiles to FileZilla config files

Occasionally I need to FTP into one of my Azure websites.  Sometimes it’s to look at the logs; other times to upload a few files.  Just about every time I go to do this, I realize that I don’t know the credentials.  So I go and download the publish profile and open it up in my favorite text editor to get the FTP information and manually enter that in FileZilla.

I quickly became tired of doing this, so I wrote a console app that will do it for me.  The source code and executable are available on my GitHub.

Usage

  1. Download your publish profile
  2. Run the command line tool
  3. Import the config file to FileZilla

Download your publish profile

Log on to the Azure management portal for the website you want to FTP into.  On the right side of the dashboard page you will see an option to “Download the publish profile.”  Click it and you’re on your way.

amp

When downloaded the file will look something like this:

<?xml version="1.0" encoding="utf-8" ?>
<publishData>
  <publishProfile
    profileName="TestSite - Web Deploy"
    publishMethod="MSDeploy"
    publishUrl="testSite.scm.azurewebsites.net:443"
    msdeploySite="testSite"
    userName="$testSite"
    userPWD="test password"
    destinationAppUrl="http://testSite.azurewebsites.net"
    SQLServerDBConnectionString=""
    hostingProviderForumLink=""
    controlPanelLink="http://windows.azure.com"
    webSystem="WebSites">
  </publishProfile>
  <publishProfile
    profileName="TestSite - FTP"
    publishMethod="FTP"
    publishUrl="ftp://waws.ftp.azurewebsites.windows.net/site/wwwroot"
    ftpPassiveMode="True"
    userName="testSite\$testSite"
    userPWD="test password"
    destinationAppUrl="http://testSite.azurewebsites.net"
    SQLServerDBConnectionString=""
    hostingProviderForumLink=""
    controlPanelLink="http://windows.azure.com"
    webSystem="WebSites">
  </publishProfile>
</publishData>

Obviously, all the pertinent connection information has been scrubbed clean.  But you get the idea.

Run the command line tool

Next thing you need to do is run pubToFz.exe to convert the publish profile into a format that FileZilla understands.  Assuming the default download location, the command would look like this:

pubToFz %home%\downloads\testSite.publishProfile

By default, the tool creates an file named FileZilla.xml in the current directory.  The file will look something like this.

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<FileZilla3>
  <Servers>
    <Server>
      <Host>waws.ftp.azurewebsites.windows.net</Host>
      <Port>21</Port>
      <Protocol>0</Protocol>
      <Type>0</Type>
      <User>testsite\$testsite</User>
      <Pass encoding="base64">base 64 encoded test password</Pass>
      <Logontype>1</Logontype>
      <TimezoneOffset>0</TimezoneOffset>
      <PasvMode>MODE_DEFAULT</PasvMode>
      <MaximumMultipleConnections>0</MaximumMultipleConnections>
      <EncodingType>Auto</EncodingType>
      <BypassProxy>0</BypassProxy>
      <Name>TestSite</Name>
      <Comments />
      <LocalDir />
      <RemoteDir />
      <SyncBrowsing>0</SyncBrowsing>
    </Server>
  </Servers>
</FileZilla3>

Again, this was scrubbed clean.

Import the config file to FileZilla

Now all you have to do is open up FileZilla and import the config file that you just saved.

fzImport

Creating Drawables for Android

One of the pains for Android development for me is creating drawables in different sizes for various devices. In the past I’d only have a few images at a time to resize so I’d normally just upload them to Android Asset Studio and have the site generate the correct sizes for me.

There are two problems with this approach.  First, I have to upload the files one at a time.  If I have more than 4 files then it becomes a bit of a chore.  Second, I can’t specify what size I want the output.  It always  generates files that are

mdpi 32×32 pixels
hdpi 48×48 pixels
xhdpi 64×64 pixels
xxhdpi 96×96 pixels

Instead of manually editing the images I had (I had a lot) I decided to finally just write an app to handle this for me.  You can find it on GitHub at AndroidIconsResizer.  Right now it is a little barebones but it quickly and easily handles batches of images.

All options are optional so the simples use is to just run it.  If nothing is specified it assumes the current directory for all input or output.  By default the output images are all squares and are 100×100 at the mdpi size.

> AndroidIconResizer

It looks for all the .png files in current directory, resizes them and copies them to the appropriate output directories.  If you ran the above command in the following directory

.
..
file.png
anotherFile.png

then the directory would look like this after

.
..
file.png
res/
    drawable-mdpi/
        file.png (100 x 100 pixels)
        anotherFile.png (100 x 100 pixels)
    drawable-hdpi/
        file.png (150 x 150 pixels)
        anotherFile.png (150 x 150 pixels)
    drawable-xhdpi/
        file.png (200 x 200 pixels)
        anotherFile.png (200 x 200 pixels)
    drawable-xxhdpi/
        file.png (300 x 300 pixels)
        anotherFile.png (300 x 300 pixels)

It is possible to specify different sizes (heights and widths) for the output images.  All you need to specify is the size you want the mdpi image.  The other sizes are extrapolated based on Google’s iconography recommendations.

> AndroidIconResizer –w 20 –h 50

You can specify the input and output directories just as easily

> AndroidIconResizer –i inputDir –o outputDir

By default the xxxhdpi image isn’t generated since it’s only needed for launcher icons.  You can choose to include it with an option

> AndroidIconResizer –-include-xxxhdpi

Or you can just ask the tool itself for some help:

> AndroidIconResizer –help

Those were all the features I needed today, but I’ll probably be expanding on this app in the future.  Let me know if you’d want any other features.

Happy Coding.

Just a little closer

As much as I love it, the resolution on my Acer Aspire S7 ultrabook can make it difficult to work in Visual Studio.  The code is just a little too small.  While the built in zoom feature is great, you need to zoom in on every document you open, which can be a little distracting, especially since I tend to not zoom in to the same zoom level each time.

What’s a developer to do?

Enter TroutZoom by Sam Trost.  Zooming in on one file resets the zoom level for all other open files as well as for all files you open afterward.  I’ve been using it for several weeks now to get a little closer to my code.  It’s a breeze to go from my laptop zoomed in at 161% to docking and zooming everything back out to 100%.