0

Is it possible to retrieve the published code from an Azure Cloud Service.

When I changed my TFS mapping, TFS wiped out the code I had written on my local machine. It converted the .csproj and .ccprof files to csproj.user and .ccproj.user files. It also removed the solution. I havn't checked anything in since February so checking out loses 3 months worth of code. I have access to some of the views, scripts, and .css files but all .cs files are gone. I have tried the following.

  1. Remote desktop into the published site. -Works but all .cs files are stored as a .dll and code is lost and "obfuscated" when decompling.
  2. Wondershare data recovery.
    • Some files are found but often in an unreadable format. Many are still missing.
  3. Getting the blob in the vsdeploy folder in Azure Storage.
    • I have the blob. Now what? Is there a way to convert that back into a readable project?
  4. Using "Open from Azure Website" extension to load the project into visual studio by the publishsettings file in Azure Portal.
    • This works great for app services, but I cannot find any existence of a .PublishSettings file in Azure. The Get-AzurePublishSettingsFile call from Windows Powershell doesn't not download the correct file. When using the extension I get a "Object not set to an instance of an object" exception. I have tested the extension with an app service and it works perfectly.
David Makogon
  • 69,407
  • 21
  • 141
  • 189
Phil Scott
  • 21
  • 4
  • No, code is compiled and that output is send to azure. It might still be in TFS, but hidden by default. See http://blogs.microsoft.co.il/eranruso/2011/01/24/show-deleted-items-in-tfs-source-control/ (still applies in 2017 :-)) – Peter Bons May 26 '17 at 20:23
  • The problem is the code I seek was never in TFS. I never checked it in. I only published it. Remapping the directory removed the code from my local machine, so the only source is the code that is published to Azure. – Phil Scott May 26 '17 at 20:29
  • Try solution 2 on this [page](https://www.codeproject.com/Questions/688944/How-to-download-Azure-Website-specifically-code-be) – ISHIDA May 26 '17 at 20:31

1 Answers1

0

If you're talking about web/worker roles in a cloud service, then no - you cannot retrieve deployed code. To get code to a cloud service, it gets packaged up first by Visual Studio (or directly through command line tools, or via Eclipse). This entails compiling all of your code first. Source files are not included in the package (unless you've explicitly done something like setting "copy local" to true in the package, which I can't imagine anyone doing).

As far as what's in blob storage: If your .cspkg is still sitting in a blob, sure, you can download and examine it. But again, it'll just contain the same package that was built locally and uploaded during deployment.

With Web Apps, your code will be available in your d:\ drive, since deployments are done via version control (unless you simply ftp something up).

With Virtual Machines (which sit in cloud services in the "classic" deployment model), you would have needed to push code to the VMs on your own (there's no built-in push-from-version-control). So again, unless you pushed source code to the VM, there's no way to retrieve said source code.

As far as the code that was wiped out on your local machine, it might be worth looking into recovery / forensic disk tools (which it looks like you've started doing), to see if your code is still sitting around somewhere, hidden. But, really, how you go about hunting for deleted / overwritten files would be off-topic (or something to ask about on SuperUser).

David Makogon
  • 69,407
  • 21
  • 141
  • 189
  • Thank you for the detailed explanation and confirming what I suspected. Can anyone recommend a tool for converting the blob housed in the vsdeploy folder in Azure to readable code? – Phil Scott May 26 '17 at 20:46
  • Maybe I was too unclear - sorry - there's no tool to convert to readable code, aside from a general .net disassembler (and you'll need to figure that out on your own). The blob is effectively just a zip file with your DLLs, configs, etc. – David Makogon May 26 '17 at 20:49