Reputation: 6487
I am using Asp.net MVC 5 on Azure websites and SQL Azure.
I have specified 2016 in the question, as I am aware of many outdated approaches.
How can I setup the SQL Azure schema? Trying to locate the script files.
Am I mistaken in using this mode, or should I be using Redis or Table Storage. Redis is obviously quite expensive, around £65 per month for cheapest 99.9% SLA option.
Thanks.
EDIT 1
It looks like MS no longer supports session management in SQL Azure, see: MS Article
As far as I understand they recommend only using Azure Redis caching. Am I correct? I am very surprised one cannot use SQL Azure. I know it may be a little slower, but it would be straightforward and reliable.
Upvotes: 3
Views: 380
Reputation: 805
Yes you should use Azure Redis. I'm not sure why sql would be more straightforward than using Redis. Using Redis is as simple as pulling in the nuget project and making the addition to the web.config to configure the session state provider as your azure Redis instance you have created. From there you can start using the Redis libraries.
<sessionState mode="Custom" customProvider="RedisSessionProvider">
<providers>
<add name="RedisSessionProvider"
type="Microsoft.Web.Redis.RedisSessionStateProvider"
port="6380"
host="YOURCACHE.cache.windows.net"
accessKey="Primary Access Key" ssl="true" />
</providers>
</sessionState>
public class HomeController : Controller
{
public ActionResult Index()
{
object value = Session["Home"];
int result = 0;
if (value != null)
{
result = (int)value;
Session["Home"] = ++result;
}
else
{
Session["Home"] = 1;
}
return View();
}
public ActionResult About()
{
object value = Session["Home"];
string home = "Didn't work";
if(value != null)
{
home = ((int)value).ToString();
}
ViewBag.Message = string.Format("The cache value is {0}", home);
return View();
}
}
Here's a link on how.
Upvotes: 3