國內環境下 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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM