2016-05-17 70 views
0

在Redis輔助方法上,我維護了2個Redis連接字符串。一個用於local,另一個用於Azure redis server。每當我需要發佈時,我都有手動改變它。我的應用程序是ASP.net MVC(SPA)應用程序。在門戶網站上設置Windows Azure Redis連接字符串

問:那麼有什麼地方可以在Azure門戶上設置發佈的Redis connection string或者我在發佈時進行發佈?

public class RedisConnectorHelper 
    { 
    private static readonly Lazy<ConnectionMultiplexer> LazyConnection = 
      new Lazy<ConnectionMultiplexer>(() => ConnectionMultiplexer.Connect("localhost,ConnectTimeout=10000"));//local host 

    //private static readonly Lazy<ConnectionMultiplexer> LazyConnection = 
    // new Lazy<ConnectionMultiplexer>(() => ConnectionMultiplexer.Connect("Myredis.redis.cache.windows.net:6380,password=mypassword,ssl=True,abortConnect=False"));//production 
} 

更新:

我已經設置在web.config.release文件,如下圖所示。

<connectionStrings> 

    <add name="Abp.Redis.Cache" connectionString="Myredis.redis.cache.windows.net:6380,password=mypassword=,ssl=True,abortConnect=False" /> 

    </connectionStrings> 

但它似乎沒有拿起它。你能告訴我爲什麼嗎?

enter image description here

+0

您的應用程序的部署方式 - 網絡應用,雲服務或虛擬機? –

+0

@GauravMantri'Web Apps' – Sampath

+0

您可以查看web.config轉換並在web.config.release文件中放入適當的連接字符串。因此,當應用程序以「釋放」模式構建時,它會從那裏獲取正確的連接字符串。 –

回答

0

這裏是trick.Cheers :)

#if DEBUG 
    private static readonly Lazy<ConnectionMultiplexer> LazyConnection = 
      new Lazy<ConnectionMultiplexer>(() => ConnectionMultiplexer.Connect("localhost,ConnectTimeout=10000"));//local host 
#else 
    private static readonly Lazy<ConnectionMultiplexer> LazyConnection = 
     new Lazy<ConnectionMultiplexer>(() => ConnectionMultiplexer.Connect("Myredis.redis.cache.windows.net:6380,password=mypassword,ssl=True,abortConnect=False"));//production 
#endif 
相關問題