none
Getting some error while my web role application trying to connect to Azure storage

    Question

  • Hello Guys,

    I have developed one Asp .Net web role application using VS 2010. What I am trying to do like, I want to upload image into Azure storage. So I have created Storage Account in windows azure developer portal. I have written code for this in my Asp .Net application. But when I run my application in VS 2010 for testing whether its working properly or not before hosting in Windows Azure. Its giving some connection problem.

    I am not sured about my connection setting. Which setting I should select for this (Use development Storage or Enter Storage Credential), when I run my application in visual studio. Currently I have selected the Enter Storage Credential and filled up all the required information like End point Protocols, Storage Account Name and Account Key.

    Rather than this do I need to do any more changes in WebRole.cs file or web.config or WebRole Settings.

    Just look at my code which I have mentioned below.

    Default.aspx.cs code

     

     

     

    CloudStorageAccount objStorage = CloudStorageAccount.FromConfigurationSetting("BlobConnectionString"); CloudBlobClient objClient = new CloudBlobClient(objStorage.BlobEndpoint, objStorage.Credentials);

    CloudBlobContainer objContainer = objClient.GetContainerReference("mycontainer"); objContainer.CreateIfNotExist();} protected void UploadImageToAzure_Click(object sender, EventArgs e) if (bwsImage.HasFile){

    String fileName = bwsImage.FileName; CloudStorageAccount objStorage = CloudStorageAccount.FromConfigurationSetting("BlobConnectionString"); CloudBlobClient objClient = new CloudBlobClient(objStorage.BlobEndpoint, objStorage.Credentials); CloudBlobContainer objContainer = objClient.GetContainerReference("mycontainer"); CloudBlob obj = objContainer.GetBlobReference(fileName.ToString()); obj.Metadata["MetaName"] = "meta";

     

     

     

     

     

    BlobStream blobstream = obj.OpenWrite(); blobstream.Write(bwsImage.FileBytes, 0, bwsImage.FileBytes.Count());IEnumerable<IListBlobItem> objBlobList = objContainer.ListBlobs();  

     

    blobstream.Close();

     

    foreach (IListBlobItem objItem in objBlobList){ "<br>");}}}}}

    Response.Write(objItem.Uri +

     

    WebRole.cs Code

    namespace

     

    WebRoleImage{ public class WebRole : RoleEntryPoint{ 

    public override bool OnStart(){ DiagnosticMonitor.Start("DiagnosticsConnectionString");

     

    CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>{ configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)); RoleEnvironment.Changed += (sender, arg) =>{ if (arg.Changes.OfType<RoleEnvironmentConfigurationSettingChange>() if (!configSetter(RoleEnvironment.GetConfigurationSettingValue(configName))){ Environment.RequestRecycle();}}};});

     

     

     

    .Any((change) => (change.ConfigurationSettingName == configName))){

     

     

    RoleEnvironment.Changing += RoleEnvironmentChanging; return base.OnStart();} private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e) if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange)) {

     

     

    {

     

     

     

     e.Cancel = true;}}}}

    Am I doing anything wrong.

    Please look into this issue and get back to me. This is very urgent.

    Thanks in Advance.

    Regards,

    Chiranjibi Das

     

     

    {

     

    namespace WebRoleImage{ public partial class _Default : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e){
    Wednesday, August 4, 2010 6:27 AM

Answers

  • Hi Chiranjibi,

    Could you try entering the command like this: DSInit /sqlInstance:.\SQLExpress /forceCreate

    Regards,

    Patriek van Dorp 


    Yours, Patriek
    Wednesday, August 18, 2010 1:56 PM

All replies

  • Hi Chiranjibi,

    What is the error message you're getting? Can you share that?

    Thanks

    Gaurav Mantri

    Cerebrata Software

    http://www.cerebrata.com

     

    Wednesday, August 4, 2010 6:35 AM
  • Hi Gaurav,

    Thanks.

    The page is not opening when I run this Asp .Net webrole application in local system. Its too slow. Yesterday there was some error related to Connection String.

    Which I guessed, might be my application is failed to connect to Azure Storage. Do I need to select "Use Development Storage" in stead of "Enter Storage Credential" Setting.

    Currently I am not able to run it.

    Just look at my code. Is my code correct?

    Wednesday, August 4, 2010 6:44 AM
  • Hi Chiranjibi,

    Have you tried to debug the code by placing breakpoints? I would start by putting breakpoints in both Page_Load() in your code behind file as well as OnStart() method in your webrole.cs file. You can try running the same code against development storage by choosing "Use Development Storage".

    Hope this helps.

    Thanks

    Gaurav

    Wednesday, August 4, 2010 6:49 AM
  • So one thing I am not getting Gaurav, If I will select "Use Development Storage", then how this application will connect to Azure Storage. Then how will I get to know before hosting the application in the actual Windows Azure whether my storage connection is working correctly or not?

    Are you getting my question?

    So Gaurav could you please explain little bit on the difference between this two setting and I want to know which setting I should select on what basis?

    Regards,

    Chiranjibi Das

    Wednesday, August 4, 2010 8:05 AM
  • Hi Chiranjibi,

    When you use "Use Development Storage", your application will connect to development storage. That way you can test your application against development storage to ensure it is working fine. Once you have made sure that your app is working fine against dev storage, you can switch this setting to connect to actual cloud storage by providing your account name and key.

    So my recommendation would be to debug your code against dev storage first.

    Hope this helps.

    Thanks

    Gaurav

    Wednesday, August 4, 2010 8:16 AM
  • Practically does it take somuch time to run, If I am running a Asp .Net web role application which is talking with azure storage?

    I want to show you the image of error message. Here I am not getting how will attach the image.

    Could you please help me out?

    Regards,

    Chiranjibi Das

    Wednesday, August 4, 2010 8:35 AM
  • Hi Chiranjibi,

    Please send me the screenshot and your project (remove your storage account keys from the configuration file before sending) in an email and I will take a look. My email address is gmantri at cerebrata dot com.

    Thanks

    Gaurav

    Wednesday, August 4, 2010 9:22 AM
  • Hi Friends,

    I am getting an error during initializing Development Storage Service.

    Thats why I am not able to run the application in my local machine.

    Either I start Development Storage Service or I do the same in Windows Azure cmd prompt. I am getting the same error everytime

    Command :  DSInit /sqlInstance:SQLExpress /forceCreate /user:*****

    Error

    Added reservation for 'http://127.0.0.1:10000/' for user account '*****'
    Added reservation for 'http://127.0.0.1:10001/' for user account '*****'
    Added reservation for 'http://127.0.0.1:10002/' for user account '*****'

    Creating database DevelopmentStorageDb20090919
    Failed to create database 'DevelopmentStorageDb20090919' : CREATE DATABASE permission denied in database 'master'.

    One or more initialization actions failed. The development storage cannot be used without resolving these errors.

    Please share with me, if you have any sloution.

    Thanks in advance.

    Regards,

    Chiranjibi Das

    Thursday, August 5, 2010 7:54 AM
  • Hi Chiranjibi,

    Could you try entering the command like this: DSInit /sqlInstance:.\SQLExpress /forceCreate

    Regards,

    Patriek van Dorp 


    Yours, Patriek
    Wednesday, August 18, 2010 1:56 PM