国内环境下 Windows 10 安装 Dapr

如果希望.Net基于Dapr在Windows上开发分布式应用程序,那么Server需要满足几个前提:

1、dapr CLI的安装 (命令行工具推荐使用PowerShell 7)

2、docker desktop (需要用到docker容器)

3、dapr 初始化安装运行时(Runtime )

4、必须要有.net SDK 

 

这篇随笔的目的就是解决第1和第3个问题。

 

由于国内网络的原因,我们无法按照官方的教程安装Dapr CLI。

所以第一步,我们需要去Dapr CLI将最新的Source code.zip下载到电脑,然后解压。

然后在Admin模式的Powershell输入以下本地安装命令:

powershell -Command "iwr -useb C:\Users\Alvin\Downloads\cli-1.5.1\install\install.ps1 | iex"

根据网上的说法,这样就能成功。但在我这里,就报错了:

PowerShell requires an execution policy of 'RemoteSigned'.

Google的回答是需要修改policy

只需要在Powershell执行

Set-ExecutionPolicy RemoteSigned

然后再次本地安装Dapr即可

 

最后,在CMD输入“Dapr”,显示如下界面,则代表Dapr Cli安装成功。

 

 

然后对Dapr初始化:

在CMD中输入Dapr init

 

一般来说就可以了。但是国内访问外网的网络太不稳定,所以仍有可能出现如下错误:

Making the jump to hyperspace...
Installing runtime version 1.5.1
Downloading binaries and setting up components...
error downloading daprd binary: Get "https://github.com/dapr/dapr/releases/download/v1.5.1/daprd_windows_amd64.zip": read tcp 192.168.31.232:52925->20.205.243.166:443: wsarecv: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

 

这时,可以参考 windows 11 dapr 环境安装

1,下载最新版的 daprd_windows_amd64.zip 以及 dashboard_windows_amd64.zip 

2,执行Dapr uninstall命令,卸载安装失败的dapr

3,再次执行Dapa init, 在C:\Users\{用户名}\.dapr\bin文件夹出现后,将这两个压缩包移动进去

4,成功

Making the jump to hyperspace...
Installing runtime version 1.5.1
Downloading binaries and setting up components...
Downloaded binaries and completed components set up.
daprd binary has been installed to C:\Users\Alvin\.dapr\bin.
dapr_placement container is running.
dapr_redis container is running.
dapr_zipkin container is running.
Use `docker ps` to check running containers.
Success! Dapr is up and running. To get started, go here: https://aka.ms/dapr-getting-started

 

 

 

参考:

云原生开发框架dapr环境搭建:CLI安装和初始化

Set the PowerShell Execution Policy to RemoteSigned

posted @ 2022-01-02 23:58  AlvinLiang  阅读(3342)  评论(1编辑  收藏  举报