azureazure-connect

With Azure Connect can I access on-premise file shares and printers from worker roles?


I'm experimenting with Azure Connect. I want to be able to push some files to an on premise server from a worker role. I'd also like to print to some network printers for some batch jobs. From what I've read I think that is supposed to be possible. I've been following this tutuorial for basics but would love pointers to any tutorials or posts specific to these two use cases.

I'm also curious if anyone knows if and when Azure Connect will be out of preview/CTP and publicly available.

Thanks

UPDATE Here's the code I used as a POC to generate a dummy file and copy it down to my on premise from a MVC web role. I got an originally got an error with the path (Error: System.IO.IOException: The network path was not found.) which I fixed by not using the fully qualified name of my on-prem box, but the short name instead and adding the firewall rule described in this post.

public class TestController : Controller
{
    public ActionResult SaveFile()
    {
        return View();
    }

    [DllImport("advapi32.dll", SetLastError = true)]
    public static extern bool LogonUser(
        string lpszUsername,
        string lpszDomain,
        string lpszPassword,
        int dwLogonType,
        int dwLogonProvider,
        out IntPtr phToken
        );

    [HttpPost]
    public ActionResult SaveFile(FormCollection collection)
    {
        try
        {
            string nowString = DateTime.UtcNow.ToString("yyyyMMdd HHmmss");

            string path = @"\\fullyqualifiedservername\e$\FileShare\";
            path = Path.Combine(path, string.Format("{0}.txt", nowString));

            IntPtr userHandle = IntPtr.Zero;
            bool loggedOn = LogonUser("myusername", "mydomain", "mypassword", 9, 0, out userHandle);

            if (loggedOn)
            {
                WindowsImpersonationContext context = WindowsIdentity.Impersonate(userHandle);
                System.IO.FileInfo f = new FileInfo(path);
                using (FileStream fs = f.OpenWrite())
                {
                    byte[] b = System.Text.Encoding.Unicode.GetBytes(string.Format("Fake content written at {0}", nowString));
                    fs.Write(b, 0, b.Length);
                }
                context.Undo();

            }

            return RedirectToAction("SaveFile");
        }
        catch(Exception ex)
        {
            ViewBag.Error = ex.ToString();
            return View();
        }
    }

}

Solution

  • Windows Azure Connect is suitable for your situation. However it has been Preview for quite a long time now (close to 2 years if I remember correctly). No one can give you idea whether/when it will become GA (General Availability).

    You can certainly experiment and build PoC (Proof Of Concept). It is fairly easy to use. You don't really need anything more than the article you refer to. There is nothing more in the Windows Azure Connect currently.

    I would, however not use it for production, as it is Preview and there is no SLA and service may go down at any given point in time.

    Another alternative with certainly brighter future is Windows Azure Virtual Network. It, however requires a real hardware router/firewall device with support of IPSEC protocols. The cheapest supported device is CISCO ASA 5505. Also you will need to provide a (managed at our side) fully functional DNS Server. You can read more about Windows Azure VN from following articles: Create a Virtual Network and Create Virtual Network for Cross Premises Connectivity.