如何让 Redis 在 Azure 上运行? [英] How to get Redis running on Azure?
本文介绍了如何让 Redis 在 Azure 上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经看到一些人在 Azure 上运行 Redis 的参考资料,但没有实现或任何类型的操作方法".有人见过这样的例子吗?
I have seen several references to people running Redis on Azure, but no implementation or any sort of 'howto' on it. Has anyone seen such an example?
推荐答案
- 下载适用于 Windows 的 Redis - 请参阅 https://github.com/ServiceStack/ServiceStack 上的适用于 Windows 的 Redis 服务构建"部分.Redis.我最终使用了 dmajkic https://github.com/dmajkic/redis/downloads 的 win64 版本
- 创建 Azure 辅助角色,删除默认类(根本不需要 c# 代码).在下载的redis源码中添加redis-server.exe文件(exe可以在redis/src中找到).
在服务定义文件中添加如下配置
- Download Redis for Windows - see the section 'Redis Service builds for Windows' on https://github.com/ServiceStack/ServiceStack.Redis. I ended up using the win64 version from dmajkic https://github.com/dmajkic/redis/downloads
- Create an Azure worker role, delete the default class (you don't need c# code at all). Add the file redis-server.exe from the downloaded redis source (the exe can be found in redis/src).
In the service definition file add the following config
<WorkerRole name="my.Worker" vmsize="Small">
<Runtime executionContext="limited">
<EntryPoint>
<ProgramEntryPoint commandLine="redis-server.exe" setReadyOnProcessStart="true" />
</EntryPoint>
</Runtime>
<Imports>
<Import moduleName="Diagnostics" />
<Import moduleName="RemoteAccess" />
<Import moduleName="RemoteForwarder" />
</Imports>
<Endpoints>
<InternalEndpoint name="Redis" protocol="tcp" port="6379" />
</Endpoints>
</WorkerRole>
您可以使用以下内容从您的 web 角色中引用 redis 服务器
You can refer to the redis server from your web role using the following
var ipEndpoint = RoleEnvironment.Roles["my.Worker"].Instances[0].InstanceEndpoints["Redis"].IPEndpoint;
host = string.Format("{0}:{1}", ipEndpoint.Address, ipEndpoint.Port);
希望有所帮助.
这篇关于如何让 Redis 在 Azure 上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文