X Blogs

who you gonna call?

... azure looks back at you

clock January 8, 2011 23:22 by author Rok Bermež

It’s been a month since Azure SKD 1.3 has been released with a lot of new features. Let’s take a look at the ability to user Remote Desktop Connection to your roles first.

In order to enable this feature we must configure our deployments to support it. The easiest way to do so is to right click on cloud service project in visual studio and choose deploys. There you can click on 'Configure Remote Desktop connections'.

Here you can enable RDP connections for all roles and you must set the required security credentials. So let’s create a security certificate first.

Then we set user credentials for our RDP account and set its expiration date.

After that, we export the security certificate so we can upload it to the cloud (you can click on view to open it directly).

We also export private key

And then we upload exported file through the Windows Azure Management portal to our chosen hosted service.

If we take a closer look at what our Visual Studio Wizard did, we can open ServiceDefinition.csdef and ServiceConfiguration.cscfg and see xml additions.


Now we can deploy our solution anyway we like.

Once the deployment is complete and our role is in 'ready' state we can download or open .rdp file through Azure Management portal.

Now we can finally connect to our instance

... and azure looks back at you

NOTE: Changes made to instance will NOT be persisted. This was meant for easier debugging. If you want to take full advantage of IIS configuration you will need to use ‘Full IIS’ feature, which will be covered in my next post.



Windws Server backup on Windows Server 2008 R2 crashing

clock December 8, 2010 21:19 by author Robi

So I wanted to change backup location of my Windows Server backups and everytime I wanted to remove or change backups the MMC was crashing.

So I wanted to do it in Windows PowerShell and found out, that by default Windows Powershell does not have module to manage Windows backups.

What you need to do is to add snapin for Windows Backup by typing:

Add-PSSnapin windows.serverbackup

Then you get all the commands that you can find here: http://technet.microsoft.com/en-us/library/ee706683.aspx.

So, to completely remove backups from Windows Server Backups, just type:

Remove-WBPolicy -All

and confirm it with: y.

Now, I can configure new backup set inside Windows Server backup MMC.

voilà



Cascading Dropdowns in InfoPath 2010

clock December 8, 2010 20:28 by author Robi

During one of my classes I got a question hot to make cascading dropdowns in InfoPath 2010 for SharePoint 2010, so here is a Visual How to:

First, you have to make lists that will hold lookup data. I made a list called KategorjaNapake which is a category list and I made TipNapake list which is a Subcategory list. I made a reference to a category list with a lookup column.

 

SubCategory list with a reference to Category list, made with a lookup column.

Columns in subcategory list:

Create columns in main list for data. First I made a column for entering text data and the second column I made was a lookup column to a category list.

 

Here are the columns I made for a main list...

Next, we will customize a SharePoint list form with InfoPath 2010...

Insert a new line in InfoPath Form

Insert a new dropdown field...

Here, just click OK, we have to go into dropdown field properties to get more choices.

If you want to display column name in SharePoint as TipNapake you have to change it here, so change field1 to name that you want to use.

To create new data source for this field, go to properties

Choose get choices from external data source and click Add.

Pick SharePoint library or list...

Pick List that you want to connect to...

Choose fields that you want to have in your data source. It is very important here to also pick the category field.

To create a cascading dropdowns, prepare yourself for a click fest. So click on the button next to Entries.

Click Filter data

Test the form in InfoPath...

Click the Quick Publish Button...

Test your form in SharePoint List....

 

voilà



Windows Azure SDK 1.3

clock December 2, 2010 00:00 by author Rok Bermež

Enhancments promised at PDC2010 are availiable for the tryout run, as well as new SDK. Get it while its hot Wink



MVC 3 beta on Windows Azure

clock November 10, 2010 19:48 by author Rok Bermež

This is also valid for RC release of MVC 3.

When preparing a demo for my next lecture I noticed that when using MVC3 beta, everything works correctly in development fabric, but it fails when deployed to Windows Azure. Web Role is cycling between initializing / stopping and that usually mean that not all dependencies are included with the deployed project.

To solve the problem just add references to the following dlls located in C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies:

  • System.WebPages.dll
  • System.Web.WebPages.Razor.dll
  • System.Web.Helpers.dll
  • System.Web.Razor.dll
  • WebMatrix.Data.dll
  • Microsoft.Web.Infrastructure.dll

and make sure that all of them (including System.Web.Mvc.dll (v3.0.0.0)) are marked as Copy local = true.



Windows Azure - Novosti

clock November 1, 2010 22:11 by author Rok Bermež

Prejšnji teden je Microsoft na PDC-ju objavil nove funkcionalnosti, ki bodo v naslednjih 12 do 18 mesecih doletele Windows Azure.  Za vse tiste, ki si dogodka niste imeli časa ogledati, je tu pregled teh funkcionalnosti, ki bodo naredile Windows Azure še bolj kompletno 'cloud' platformo:

-          Dobimo novo VM vlogo, ki nam bo omogočala nalaganje svojega VHD  virtualnega diska in njegov zagon  v oblaku ter bo v začetku podpirala operacijske sisteme Windows Server 2008 R2, 2011 (ko bo na voljo), Windows Server 2003 in Windows Server 2008 s Service Pack 2. Malce kasneje, proti koncu naslednjega leta,  pride tudi 'Server Application Virtualization', ki bo omogočal nameščanje strežniških aplikacij v oblak brez potrebe po njihovem pakiranju v VHD-je. Pred tem, do konca letošnjega leta, pa dobimo administratorske pravice  in oddaljen dostop (RDP) do obstoječih VM-jev, tako da bomo lahko nanje nameščali stvari, ki jih do zdaj nismo mogli.

-          SQL Azure se z pridobitvijo  SQL Azure Reportinga in dodatnih storitev za sinhronizacijo, ki nam bodo omogočale replikacijo podatkov na lokalne strežnike in mobilne naprave, hitro približuje svojemu strežniškemu bratu. Predogled obeh storitev naj bi bil omogočen še letos.

-          Tudi AppFabric dobi nekaj novosti -  distribuiran 'cacheing', lažjo integracijo z BizTalk strežnikom ter kompozitne aplikacije.

-          Kot konkurenco Amazonovi novi micro instanci, dobimo 'Extra Small' velikost VM-ja, ki pri ceni $0,05 / compute hour precej zniža vstopni prag malih podjetij v oblak.

Z vsemi napovedanimi novostmi bo Windows Azure trenutno zagotovo najpopolnejša ponudba oblaka.



Bulletproof Cross-Browser CSS Techniques

clock October 13, 2010 18:44 by author Klemen Slavič

I've written up a summary of all tehniques and tricks for cross-browser CSS coding I've learned over the years in a guest post on Script Junkie. It's meant to be a starting and reference point for anyone from beginner to advanced levels.

Have a look.



Using MVC routing to address multi-tenant Azure applications

clock October 11, 2010 19:29 by author Rok Bermež

Currently I have a scenario where I have to have more than one site and multiple domains/subdomains in a single Windows Azure web role.
For obvious reasons Windows Azure give us FQDN (like myapp.cloudapp.net) instead of IP address so we have to use CNAME to point to our instance/s. The only problem with this approach is that only domain name cannot have CNAME record. For instance www.mydomain.org is fine, but just mydomain.org is not since it needs specific IP address. For the time being this was solved by pointing it to some specific address which would redirect the user to www of that domain.

That part was simple and straightforward, but now we need something inside our web role, that would detect requested domain and serve appropriate content. There are a couple of threads online that deal with the issue of addressing multi-tenant application in Windows Azure and most of them deal with url rewriting on the single domain. You can read more about it here and here.

In my project I used MVC Areas to separate different sites so all I needed was MVC routing to use domain name from incoming request in its routing configuration. I found an excellent article on the subject here, but unfortunately it was written before MVC 2 introduced areas, so in order to use it lets add area support to it.

First lets download the sample here, open and if needed convert solution and open DomainRoute.cs. We only need to add one line to the end of GetRouteData method:

if (Defaults.Keys.Contains("area"))
data.DataTokens.Add("area", Defaults["area"]);

so that it looks like:

         if (DataTokens != null)
                {
                    foreach (var token in DataTokens)
                    {
                        data.DataTokens.Add(token.Key, token.Value);
                    }
                }
                if (Defaults.Keys.Contains("area"))
data.DataTokens.Add("area", Defaults["area"]); } return data; }

 

And we are ready to register our areas as their own domains/subdomains

        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.Routes.Add("subodomain_default", new DomainRoute(
           "subdomain.mydomain.si",                                     
           "{controller}/{action}/{id}",            
           new { area = AreaName, controller = "Home", action = "Index",
id = UrlParameter.Optional } ) { DataTokens = new RouteValueDictionary(new {
Namespaces = new string[] { "MvcWebRole1.Areas.subdomain.Controllers" } }) } ); }

 I strongly suggest you pass Namspaces to every route registration so you can have multiple controllers with the same name serving different tenants. Soon Ill add a DomainRouteExtension and post it here so the usage will be even simpler.



RadEditor MVC Helper Sample

clock September 9, 2010 00:09 by author Rok Bermež

I was asked for RadEditor MVC helper, so here it goes (copy paste code out) :

        public static MvcHtmlString RadEditorFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression) where TModel : class
        {

            return RadEditorFor(htmlHelper, expression, ((IDictionary<string, object>)null));
        }

        public static MvcHtmlString RadEditorFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, object htmlAttributes) where TModel : class
        {
            return RadEditorFor(htmlHelper, expression, new RouteValueDictionary(htmlAttributes));
        }

        public static MvcHtmlString RadEditorFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IDictionary<string, object> htmlAttributes) where TModel : class
        {
            string name = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(ExpressionHelper.GetExpressionText((LambdaExpression)expression));
            TProperty value = ExpressionHelper2.GetValue(htmlHelper, expression);
            return RadEditor(htmlHelper, name, value, htmlAttributes);
        }

        public static MvcHtmlString RadEditor(this HtmlHelper htmlHelper, string name)
        {
            return RadEditor(htmlHelper, name, null);
        }

        public static MvcHtmlString RadEditor(this HtmlHelper htmlHelper, string name, object value)
        {
            return RadEditor(htmlHelper, name, null, ((IDictionary<string, object>)null));
        }

        public static MvcHtmlString RadEditor(this HtmlHelper htmlHelper, string name, object value, object htmlAttributes)
        {
            return RadEditor(htmlHelper, name, value, new RouteValueDictionary(htmlAttributes));
        }

        public static MvcHtmlString RadEditor(this HtmlHelper htmlHelper, string name, object value, IDictionary<string, object> htmlAttributes)
        {
            if (String.IsNullOrEmpty(name))
            {
                name = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(name);
                if (string.IsNullOrEmpty(name))
                {
                    throw new ArgumentException("name");
                }
            }
            if (htmlAttributes == null) htmlAttributes = new Dictionary<string, object>();
            Page page = new Page();
            RadMvcScriptManager mvcScriptManager = new RadMvcScriptManager();
            mvcScriptManager.EnableViewState = false;
            page.Controls.Add(mvcScriptManager);
            RadStyleSheetManager radStyleSheetManager = new RadStyleSheetManager();
            page.Controls.Add(radStyleSheetManager);

            //string id = name.Replace(".", "_");
            RadEditor radEditor = new RadEditor();

            radEditor.ID = name + "_radeditor";
            radEditor.ClientIDMode = ClientIDMode.Static;

            radEditor.ImageManager.ContentProviderTypeName = typeof(AzureStorageFileBrowserContentProvider).AssemblyQualifiedName;
            radEditor.ImageManager.MaxUploadFileSize = 3000000;
            radEditor.ImageManager.ViewPaths = new string[] { "uploaded/images" };
            radEditor.ImageManager.UploadPaths = new string[] { "uploaded/images" };
            radEditor.ImageManager.DeletePaths = new string[] { "uploaded/images" };

            radEditor.DocumentManager.ContentProviderTypeName = typeof(AzureStorageFileBrowserContentProvider).AssemblyQualifiedName;
            radEditor.DocumentManager.MaxUploadFileSize = 20000000;
            radEditor.DocumentManager.ViewPaths = new string[] { "uploaded/documents" };
            radEditor.DocumentManager.UploadPaths = new string[] { "uploaded/documents" };
            radEditor.DocumentManager.DeletePaths = new string[] { "uploaded/documents" };

            radEditor.MediaManager.ContentProviderTypeName = typeof(AzureStorageFileBrowserContentProvider).AssemblyQualifiedName;
            radEditor.MediaManager.MaxUploadFileSize = 50000000;
            radEditor.MediaManager.ViewPaths = new string[] { "uploaded/media" };
            radEditor.MediaManager.UploadPaths = new string[] { "uploaded/media" };
            radEditor.MediaManager.DeletePaths = new string[] { "uploaded/media" };

            radEditor.FlashManager.ContentProviderTypeName = typeof(AzureStorageFileBrowserContentProvider).AssemblyQualifiedName;
            radEditor.FlashManager.MaxUploadFileSize = 50000000;
            radEditor.FlashManager.ViewPaths = new string[] { "uploaded/flash" };
            radEditor.FlashManager.UploadPaths = new string[] { "uploaded/flash" };
            radEditor.FlashManager.DeletePaths = new string[] { "uploaded/flash" };

            //radEditor.TemplateManager.ContentProviderTypeName = typeof(AzureStorageFileBrowserContentProvider).AssemblyQualifiedName;
            radEditor.TemplateManager.MaxUploadFileSize = 500000;
            radEditor.TemplateManager.ViewPaths = new string[] { "~/content/templates" };

            radEditor.NewLineBr = false;

            radEditor.Skin = "Vista";

            //radEditor.ToolsFile = "~/Content/administracija/EditorToolbar.xml";
            if (htmlAttributes.ContainsKey("ToolsFile")) radEditor.ToolsFile = htmlAttributes["ToolsFile"] as string;
            UIHintControlParameterDataAnnotationsModelMetadata mmd = (UIHintControlParameterDataAnnotationsModelMetadata)htmlHelper.ViewData.ModelMetadata;
            if (mmd.TemplateControlParameterExist("ToolBar"))
            {
                radEditor.ToolsFile = mmd.GetTemplateControlParameter<string>("ToolBar");
            }
            if (mmd.TemplateControlParameterExist("DisableHtmlFormating") && mmd.GetTemplateControlParameter<bool>("DisableHtmlFormating"))
            {
                radEditor.StripFormattingOptions = EditorStripFormattingOptions.None;
                radEditor.DisableFilter(Telerik.Web.UI.EditorFilters.ConvertToXhtml);

            }
            if (value != null) radEditor.Content = value as string;
            radEditor.DialogHandlerUrl = "/Telerik.Web.UI.DialogHandler.axd";
            page.Controls.Add(radEditor);
            StringWriter output = new StringWriter();
            HttpContext.Current.Server.Execute(page, output, false);

            return MvcHtmlString.Create(htmlHelper.Hidden("", "ToBeReplaced").ToString() + output.ToString());
        }


Telerik ASP.NET AJAX Controls in MVC project Part ||

clock September 4, 2010 00:09 by author Rok Bermež

Some controls explicitly require to be placed within

tag. To go around this issue you can do something like this (telerik reporting used in MVC project):
public class NoServerFormPage: Page
        {
            public override void VerifyRenderingInServerForm(Control control)
            {
                // to avoid the server form (<form runat="server">) requirement
            }
        }
        
        public static MvcHtmlString TelerikReport(this HtmlHelper htmlHelper, object  value, object htmlAttributes )
        {
            NoServerFormPage page = new NoServerFormPage();
            RadMvcScriptManager mvcScriptManager = new RadMvcScriptManager();
            mvcScriptManager.EnableViewState = false;
            page.Controls.Add(mvcScriptManager);
            RadStyleSheetManager radStyleSheetManager = new RadStyleSheetManager();
            page.Controls.Add(radStyleSheetManager);

            ReportViewer reportViewer = new ReportViewer();
            reportViewer.ID = "whoCares";
            reportViewer.Height = 890;
            reportViewer.Width = 700;
            
            reportViewer.ToolbarVisible = true;
            reportViewer.Report = new Ntk.Reports.Racun();
            ((Telerik.Reporting.Report)reportViewer.Report).ReportParameters["ID"].Value = value;
            reportViewer.Resources.CurrentPageToolTip = "Trenutna stran";
            reportViewer.Resources.ExportButtonText = "Izvozi";
            reportViewer.Resources.ExportSelectFormatText = "Izberi format za izvoz";
            reportViewer.Resources.ExportToolTip = "Izvoz";
            reportViewer.Resources.FirstPageToolTip = "prva stran";
            reportViewer.Resources.LabelOf = "od";
            reportViewer.Resources.LastPageToolTip = "Zadnja stran";
            reportViewer.Resources.NextPageToolTip = "naslednja stran";
            reportViewer.Resources.PreviousPageToolTip = "prejšnja stran";
            reportViewer.Resources.PrintToolTip = "Natisni";
            reportViewer.Resources.ProcessingReportMessage = "Nalagam...";
            reportViewer.Resources.RefreshToolTip = "Osveži";
            

            page.Controls.Add(reportViewer);
            StringWriter output = new StringWriter();
            HttpContext.Current.Server.Execute(page, output, false);

            return MvcHtmlString.Create(output.ToString());
        }


About the author

Rok Bermež is Slovenian Windows Azure MVP, he works as a Software Engineer and Microsoft Certified Trainer at Kompas Xnet. His primary interests include cloud computing and web development. With extensive experience in development and architecture he participated in many projects and since the CTP release of Windows Azure much of those projects are based on Windows Azure platform. Rok has been delivering courses, writing code and speaking at conferences and community events on Microsoft technologies for the last couple of years. You can also find him on Twitter (@Rok_B).

Month List

Sign In