tag:blogger.com,1999:blog-79657627411973799212024-03-14T04:46:48.097+09:00Windowsを使わないAzureの人クライアントはMacOSX、サーバーはLinuxとかBSDとか。
それでもMicrosoftAzureの仕事をしている。
Microsoft MVP (Azure) 2015 - 2018。Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.comBlogger227125tag:blogger.com,1999:blog-7965762741197379921.post-77177761888995097592019-07-09T10:54:00.003+09:002019-07-09T10:57:40.535+09:00【Microsoft Azure】 Azure Kinect Sensor SDK on Linux っていうか Ubuntu 18.04 にインストールしてみる<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: "helvetica neue";">Azure Kineck DK </span><span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;">が発売されたので、</span><span style="font-family: "helvetica neue";">SDK</span><span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;">を準備してみます@</span><span style="font-family: "helvetica neue";">Ubuntu</span><span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;">。</span></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
なお、<span style="font-family: "helvetica neue"; font-stretch: normal; line-height: normal;">Windows</span>での準備はこちらのぶちぞーさんのブログをどうぞ。</div>
<div style="color: #dca10d; font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<a href="https://blog.azure.moe/2019/07/05/azure-kinect-sensor-sdk-">https://blog.azure.moe/2019/07/05/azure-kinect-sensor-sdk-</a><span style="color: black; font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;">(メモ)</span><span style="color: black;">/</span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<br /></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
SDK<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;">は現時点では</span>Ubuntu18.04<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;">(</span>bionic<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;">)のみ対応になります。</span></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
詳しくは公式ドキュメントをご覧ください。</div>
<div style="color: #dca10d; font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<a href="https://docs.microsoft.com/ja-jp/azure/Kinect-dk/sensor-sdk-download">https://docs.microsoft.com/ja-jp/azure/Kinect-dk/sensor-sdk-download</a></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<br /></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: "helvetica neue"; font-stretch: normal; line-height: normal;">SDK</span>をインストールする前に、<span style="font-family: "helvetica neue"; font-stretch: normal; line-height: normal;">Microsoft</span>のパッケージリポジトリを参照する必要があります。</div>
<div style="color: #dca10d; font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<a href="https://docs.microsoft.com/ja-jp/windows-server/administration/linux-package-repository-for-microsoft-software">https://docs.microsoft.com/ja-jp/windows-server/administration/linux-package-repository-for-microsoft-software</a></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<br /></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
リポジトリの設定から行いましょう。</div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
なお、ここからはターミナルからコマンドを入力するスタイルで参ります。</div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
面倒なので管理者権限で行なっていますが、良い子は<span style="font-family: "helvetica neue"; font-stretch: normal; line-height: normal;">sudo</span>を使いましょうね。</div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<div style="background-color: rgba(0, 0, 0, 0.901961); color: lime; font-family: "Hiragino Kaku Gothic ProN"; font-size: 18px; font-stretch: normal; line-height: normal;">
<span style="background-color: black; font-size: 12px;"># curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -</span></div>
<div style="background-color: rgba(0, 0, 0, 0.901961); color: lime; font-family: "Hiragino Kaku Gothic ProN"; font-size: 18px; font-stretch: normal; line-height: normal;">
<span style="background-color: black; font-size: 12px;"># apt-add-repository https://packages.microsoft.com/ubuntu/18.04/prod </span></div>
</div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: "helvetica neue"; font-stretch: normal; line-height: normal;"><br /></span>
<span style="font-family: "helvetica neue"; font-stretch: normal; line-height: normal;">64bit</span>環境では<span style="font-family: "helvetica neue"; font-stretch: normal; line-height: normal;">i386</span>アーキテクチャをサポートしていない旨が表示されますが、問題ないので続けます。</div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<br /></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
準備ができたので、まず<span style="font-family: "helvetica neue"; font-stretch: normal; line-height: normal;"> k4a-tools </span>をインストールします。</div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;">このパッケージは</span> Azure Kinect Viewer<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;">、</span>Azure Kinect Recorder<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;">、</span>Azure Kinect Firmware Tool <span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;">が含まれます。</span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="background-color: black;"><span style="color: lime;"># apt install k4a-tools </span></span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
インストールが終わったら、次は開発用のヘッダーを含むライブラリをインストールします。</div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="background-color: black;"><span style="color: lime;"># apt install libk4a1.1-dev </span></span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
これでインストールは完了です。</div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<br /></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
ここからはデスクトップが必要になりますので、コマンドはデスクトップアプリのターミナルなどから入力します。</div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<br /></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;">早速、</span>Azure Kinect Viewer <span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;">を起動してみましょう。</span></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
ターミナルで以下のコマンドを入力するとウィンドウが開きます。</div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="background-color: black;"><span style="color: lime;"># k4aviewer </span></span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-IyGi8SLMyp0/XSPy3zG1WwI/AAAAAAAAB0I/7ZyO9CefBcAiebRaig5cNKelvqO9NpbuQCLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2019-07-09%2B9.59.26.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="985" data-original-width="1600" height="197" src="https://1.bp.blogspot.com/-IyGi8SLMyp0/XSPy3zG1WwI/AAAAAAAAB0I/7ZyO9CefBcAiebRaig5cNKelvqO9NpbuQCLcBGAs/s320/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2019-07-09%2B9.59.26.png" width="320" /></a></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
こちらも実機がないので、レコーディングされたデータを再生。</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-DVi2RYMvgw0/XSPy3-ImxgI/AAAAAAAAB0A/wietFNLmnq8R9wI7nX_RRqfuiX5m1msyQCEwYBhgL/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2019-07-09%2B10.10.40.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="973" data-original-width="1513" height="205" src="https://1.bp.blogspot.com/-DVi2RYMvgw0/XSPy3-ImxgI/AAAAAAAAB0A/wietFNLmnq8R9wI7nX_RRqfuiX5m1msyQCEwYBhgL/s320/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2019-07-09%2B10.10.40.png" width="320" /></a></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<br /></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br /></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<br />
<br />
<br />
<br />
<br />
<br />
<br /></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: "helvetica neue";">Perfomance Counters </span><span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;">も出ます。</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-Q8DZDIBHVS0/XSPy38Eey0I/AAAAAAAAB0E/nhJfKzFE-Gkqww00bdUE2BC6eIe9DaaZwCEwYBhgL/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2019-07-09%2B10.32.53.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="321" data-original-width="247" height="320" src="https://1.bp.blogspot.com/-Q8DZDIBHVS0/XSPy38Eey0I/AAAAAAAAB0E/nhJfKzFE-Gkqww00bdUE2BC6eIe9DaaZwCEwYBhgL/s320/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2019-07-09%2B10.32.53.png" width="248" /></a></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<br /></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<br /></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;"><br /></span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;"><br /></span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;"><br /></span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;"><br /></span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;"><br /></span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;"><br /></span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;"><br /></span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;"><br /></span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;"><br /></span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;"><br /></span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;"><br /></span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;"><br /></span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;"><br /></span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;"><br /></span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;"><br /></span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;"><br /></span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;"><br /></span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;"><br /></span></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;">なお、</span>Ubuntu 18.04 <span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;">の</span> OpenGL <span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;">が古いのか、</span>3D<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;">表示にすると「</span>GLSL 4.30 is not supported.<span style="font-family: ".hiragino kaku gothic interface"; font-stretch: normal; line-height: normal;">」で落ちます。</span></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
対応するには自前で<span style="font-family: "helvetica neue"; font-stretch: normal; line-height: normal;">OpenGL</span>をコンパイルする必要がありますので、こちらを参考にコンパイルしてみてください。</div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: "helvetica neue"; font-stretch: normal; line-height: normal;">#</span>うちのグラボがしょぼいからかもしれないが<span style="font-family: "helvetica neue"; font-stretch: normal; line-height: normal;">…</span></div>
<div style="color: #dca10d; font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<a href="https://github.com/JoeyDeVries/LearnOpenGL">https://github.com/JoeyDeVries/LearnOpenGL</a></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<br /></div>
<br />
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
一通り動きそうなので、実機を楽しみに待つことにします。</div>
<div>
<br /></div>
Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0tag:blogger.com,1999:blog-7965762741197379921.post-61204550672277441112018-10-02T16:35:00.003+09:002018-10-02T16:35:49.544+09:00【Microsoft Azure】Azure IoT Hub と相性の良さそうなデバイスを独断と偏見で<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: "Helvetica Neue"; font-stretch: normal; line-height: normal;">IoT</span>というとラズパイがまず出てくるようになって久しいですが、<span style="font-family: "Helvetica Neue"; font-stretch: normal; line-height: normal;">3</span>になってからは消費電力も多く、実質省電力<span style="font-family: "Helvetica Neue"; font-stretch: normal; line-height: normal;">PC</span>になってきているようです。</div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
本来<span style="font-family: "Helvetica Neue"; font-stretch: normal; line-height: normal;">IoT</span>デバイスに求められるのは、省電力でネットワーク接続ができることではないだろうかと思うのですがどうなんでしょう。</div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<br /></div>
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
という訳で、<span style="font-family: "Helvetica Neue"; font-stretch: normal; line-height: normal;">Azuere Sphere </span>も手元に届いたので、<span style="font-family: "Helvetica Neue"; font-stretch: normal; line-height: normal;">Azure IoT</span>を利用する観点から、自分が関わったりしているものを含めて技適も通ってるもの<span style="font-family: "Helvetica Neue"; font-stretch: normal; line-height: normal;">3</span>つをピックアップして独断と偏見で比較してみようかと思います。</div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<br /></div>
<table cellpadding="0" cellspacing="0" style="border-collapse: collapse;">
<tbody>
<tr>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
デバイス</div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<a href="https://www.switch-science.com/catalog/3647/" target="_blank">M5Stack</a><span style="font-family: ".Hiragino Kaku Gothic Interface"; font-stretch: normal; line-height: normal;">(</span>ESP32<span style="font-family: ".Hiragino Kaku Gothic Interface"; font-stretch: normal; line-height: normal;">)</span></div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<a href="http://akizukidenshi.com/catalog/g/gM-13677/" target="_blank">MT3620</a><span style="font-family: ".Hiragino Kaku Gothic Interface"; font-stretch: normal; line-height: normal;">(</span>Azure Sphere<span style="font-family: ".Hiragino Kaku Gothic Interface"; font-stretch: normal; line-height: normal;">)</span></div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
<a href="https://www.amazon.co.jp/Toshiba-Flashair-w-04-16-SDHC%E3%82%AF%E3%83%A9%E3%82%B910%E3%83%A1%E3%83%A2%E3%83%AA%E3%82%AB%E3%83%BC%E3%83%89/dp/B0799LCRG8/ref=sr_1_fkmr0_1?s=computers&ie=UTF8&qid=1538464876&sr=1-1-fkmr0&keywords=flash+Air+w-04+16" target="_blank">FlashAir W-04 16GB</a></div>
</td>
</tr>
<tr>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
特徴</div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
ディスプレイとバッテリーが一体化している。</div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
セキュリティ確保を目的とした<span style="font-family: "Helvetica Neue"; font-stretch: normal; line-height: normal;">AzureSphereOS</span>を搭載。</div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: "Helvetica Neue"; font-stretch: normal; line-height: normal;">Wi-Fi</span>機能をもち、<span style="font-family: "Helvetica Neue"; font-stretch: normal; line-height: normal;">Lua</span>プログラムが実行できる<span style="font-family: "Helvetica Neue"; font-stretch: normal; line-height: normal;">SD</span>カード。<span style="font-family: "Helvetica Neue"; font-stretch: normal; line-height: normal;">GPIO</span>を利用してマイコンとして利用可能。</div>
</td>
</tr>
<tr>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
価格</div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: "Helvetica Neue"; font-stretch: normal; line-height: normal;">4</span>,<span style="font-family: "Helvetica Neue"; font-stretch: normal; line-height: normal;">490</span>円(スイッチサイエンス)</div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: "Helvetica Neue"; font-stretch: normal; line-height: normal;">9</span>,<span style="font-family: "Helvetica Neue"; font-stretch: normal; line-height: normal;">800</span>円(秋月)</div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
4<span style="font-family: ".Hiragino Kaku Gothic Interface"; font-stretch: normal; line-height: normal;">,</span>410<span style="font-family: ".Hiragino Kaku Gothic Interface"; font-stretch: normal; line-height: normal;">円(</span>Amazon<span style="font-family: ".Hiragino Kaku Gothic Interface"; font-stretch: normal; line-height: normal;">公式)</span></div>
</td>
</tr>
<tr>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
開発<span style="font-family: "Helvetica Neue"; font-stretch: normal; line-height: normal;">OS</span></div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
Windows<span style="font-family: ".Hiragino Kaku Gothic Interface"; font-stretch: normal; line-height: normal;">、</span>MacOS<span style="font-family: ".Hiragino Kaku Gothic Interface"; font-stretch: normal; line-height: normal;">、</span>Linux</div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
Windows</div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
テキストファイルが扱えれば何でも</div>
</td>
</tr>
<tr>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
開発言語</div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
Processing</div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
C++</div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
Lua</div>
</td>
</tr>
<tr>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
開発ツール</div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
Arduino IDE</div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
Visual Studio</div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
テキストファイル</div>
</td>
</tr>
<tr>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal;">
Azure IoT SDK</div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<a href="https://github.com/Azure/azure-iot-arduino" target="_blank">公式あり</a></div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<a href="https://docs.microsoft.com/ja-jp/azure-sphere/install/install" target="_blank">公式あり</a></div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<a href="https://github.com/cocteau666/FlashAir_AzureIoT" target="_blank"><span style="font-family: "Helvetica Neue"; font-stretch: normal; line-height: normal;">GitHub</span>にある</a>(←私が作ったw)</div>
</td>
</tr>
<tr>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
備考</div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
基盤はケースに入っている。拡張センサーは<span style="font-family: "Helvetica Neue"; font-stretch: normal; line-height: normal;">Grove</span>などでも接続できる。</div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
基盤むき出しの開発キット。実は Device Provisioning Service に対応している。</div>
</td>
<td style="border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; padding: 1.0px 5.0px 1.0px 5.0px;" valign="top">
<div style="font-family: ".Hiragino Kaku Gothic Interface"; font-size: 12px; font-stretch: normal; line-height: normal;">
<span style="font-family: "Helvetica Neue"; font-stretch: normal; line-height: normal;">SD</span>カードなので<span style="font-family: "Helvetica Neue"; font-stretch: normal; line-height: normal;">GPIO</span>ピンへの接続は別途基盤が必要</div>
</td>
</tr>
</tbody>
</table>
<br />
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<br /></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
なお、ESP32は開発用のESP-WROOT-32というパッケージだともっと安く買える(もちろん基盤むき出し)ので、頑張って探してみてもいいかもしれません。</div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<br /></div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
Azure Sphere OS は手元にデバイスがあるのでいろいろいじってみてまとめたいと思います。</div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
シリアルコンソールからログインできないのは若干面白みに欠けますが...</div>
<div style="font-family: "Helvetica Neue"; font-size: 12px; font-stretch: normal; line-height: normal; min-height: 14px;">
<br /></div>
Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0tag:blogger.com,1999:blog-7965762741197379921.post-63384480968101312642018-08-16T10:45:00.001+09:002018-08-16T10:45:37.441+09:00my bloody valentine 2018/08/15 ToyosuPIT @Tokyo, JAPANSET LIST<br />
<br />
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545}
</style>
<br />
<div class="p1">
i only said</div>
<div class="p1">
when you sleep</div>
<div class="p1">
new you</div>
<div class="p1">
new song 2</div>
<div class="p1">
you never should</div>
<div class="p1">
honey power</div>
<div class="p1">
new song 1</div>
<div class="p1">
cigarette in your bed</div>
<div class="p1">
only tomorrow</div>
<div class="p1">
only shallow</div>
<div class="p1">
what you want</div>
<div class="p1">
thorn</div>
<div class="p1">
nothing much to lose</div>
<div class="p1">
who sees you</div>
<div class="p1">
to here knows when</div>
<div class="p1">
slow</div>
<div class="p1">
soon</div>
<div class="p1">
wonder 2</div>
<div class="p1">
feed me with your kiss</div>
<div class="p1">
you made me realise</div>
<br /><br />
15日は2013年の東京国際フォーラム以来の単独ライブでした。<br />
2008年のFujiRock以降だいたいの公演見てるので、今回も参戦。<br />
<br />
ケヴィンがバーガンディーミストのJaguarとかHiWattのアンプ使ってたり。<br />
なお、彼のギターに関してはこちらにFenderのインタビューがあります。<br />
<h1 style="-webkit-font-smoothing: antialiased; background-color: white; box-sizing: border-box; caret-color: rgb(0, 0, 0); font-family: futurapt-heavy; letter-spacing: 0.3px; line-height: 1.3em; margin: 0px 0px 16px; padding: 0px; text-size-adjust: auto;">
<span style="font-size: small;"><a href="https://shop.fender.com/ja-JP/interview-my-bloody-valentines-kevin-shields-on-the-jazzmaster-and-his-iconic-albums" target="_blank">Jazzmasterレジェンド、ケヴィン・シールズとメインギター。</a></span></h1>
サポートのキーボード/ギターの<span style="background-color: white; caret-color: rgb(34, 34, 34); color: #222222; font-family: Osaka; font-size: 14px;"><a href="https://twitter.com/apostrophewife" target="_blank">Jen Macro</a></span>もいい感じで馴染んでます。<br />
<a href="https://www.hurtlingband.com/" target="_blank">HURTLiNG</a>というバンドをやってて、ボーカル/ギターです。<br />
浮遊感あるバンドですので、一聴の価値ありです。<br />
<br />
野太いビリンダコールに、ビリンダがたまに反応してたり。<br />
Marshall2台+Vox(たぶんAC30)2台のアンプ鳴らしてあちらも轟音。<br />
なお、途中弾いてたシンセはたぶんJunoか。<br />
<br />
デビー姐さんが相変わらずのかっこよさでベース弾きまくり、コーラスも綺麗で。<br />
RDとおそらくオーダーメイドのJaguarベースと、DevidedBy13のヘッド2台にMarshallのキャビ2台でこちらも強烈。<br />
wonder2ではFender Jaguarを使用。<br />
<br />
コルムさん、AbbyRoadの頃のジョージ・ハリスンみたいに見えました(個人的感想)が、プレイは相変わらずキース・ムーン。<br />
前回はPremierだった気もしますが(ちょっと覚えてない)、今回はLudwigのブルースパークル。<br />
wonder2のギターはデビーと同じくFender Jaguar。<br />
それ用なのか小さなVoxのコンボも置いてあった。<br />
<br />
新曲は2曲。<br />
1曲はピストルズみたいなコード進行のパンクかと思いきや、真ん中でNothing Much To Loseのイントロみたいになったり。<br />
もう1曲は6/8のゆったりした浮遊感のある感じ。<br />
予告されてるEPの曲でしょうかね。<br />
<br />
なお、20曲もやったのは驚きでした。<br />
12〜14曲ぐらいかと思ってましたが、新曲とmbvの曲を加えて、今までのライブの定番も全てやるとこの曲数ってことでしょう。<br />
<br />
個人的には new you のケヴィンが弾くトレモロサウンド(おそらくBOSSのPN2だと思われる揺れ方)が気持ち良い音でした。<br />
思ったよりペダルが多くない印象でしたが、残念ながら足元を見れなかったので確認できず。<br />
<br />
wonder2ではお約束の全員ギター。<br />
最後は言わずもがなのNoisePitだけど、聞く側がすっかり慣れてきたせいかいい感じのサイズでケヴィン先生切り上げてたように見えましたw<br />
なお、ノイズ終る時の「ケヴィンがデビーを見る→デビーがコルムと合わせてベースを高く構えて振り下ろす→曲に戻る」瞬間が大好きです。<br />
曲の終わりに、ケヴィン先生最後のノイズをカマしてきたのが悪戯っぽくてツボでした。<br />
<br />
17日のSonicManiaは90分ぐらいのようなので、また違うセットになるのでしょうか。<br />
確認がてら次も行ってきます。<br />
<br />Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0tag:blogger.com,1999:blog-7965762741197379921.post-81956158893729078392018-06-12T11:02:00.002+09:002018-06-12T11:08:53.078+09:00【Microsoft Azure】ESP-WROOM-32 から Azure IoT Hub に接続してみる最近勝手にあらゆるデバイスを Azure IoT Hub に接続するキャンペーンをしています。<br />
一応前提として、MacOSXでの日本語環境で開発します。<br />
<br />
今回は、Espressif Systems の ESP-WROOM-32 という無線通信モジュールから接続してみます。<br />
<a href="https://www.switch-science.com/catalog/3156/">https://www.switch-science.com/catalog/3156/</a><br />
<br />
ESP-WROOM-32は、Arduinoではないのですが、Arduino IDEで開発ができます。今回は開発キットである ESPr Developer 32 を使います。<br />
<a href="https://www.switch-science.com/catalog/3210/">https://www.switch-science.com/catalog/3210/</a><br />
<br />
セットアップ方法については以下を参照してください。<br />
<a href="http://trac.switch-science.com/wiki/esp32_setup">http://trac.switch-science.com/wiki/esp32_setup</a><br />
<br />
それでは、Arduino IDE から、Azure IoT Hub の GetStartedサンプルを使って接続してみます。<br />
<br />
Arduino IDE を立ち上げて、ボードの設定をします。<br />
「ツール>ボード>ESP32 Dev Module」を選択します。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-vJjfM_tisqM/Wx8lN_nuulI/AAAAAAAABsY/IophK8bNjL8aUsE_q-2L947Smhjxfe3fACLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-06-12%2B10.39.23.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="1132" data-original-width="929" height="400" src="https://4.bp.blogspot.com/-vJjfM_tisqM/Wx8lN_nuulI/AAAAAAAABsY/IophK8bNjL8aUsE_q-2L947Smhjxfe3fACLcBGAs/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-06-12%2B10.39.23.png" width="327" /></a></div>
<br />
<br clear="all" />
<br />
次に、シリアルポートの設定を行います。<br />
「ツール>シリアルポート>/dev/cu.SLAB_USBtoUART」を選択します。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-UAgPPV1xBoA/Wx8lPocPmCI/AAAAAAAABsc/DLKxdtd3lB8UDiTmkkTFJRtKrrlPsJ4AQCLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-06-12%2B10.40.18.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="391" data-original-width="901" height="172" src="https://3.bp.blogspot.com/-UAgPPV1xBoA/Wx8lPocPmCI/AAAAAAAABsc/DLKxdtd3lB8UDiTmkkTFJRtKrrlPsJ4AQCLcBGAs/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-06-12%2B10.40.18.png" width="400" /></a><a href="https://3.bp.blogspot.com/-UAgPPV1xBoA/Wx8lPocPmCI/AAAAAAAABsc/DLKxdtd3lB8UDiTmkkTFJRtKrrlPsJ4AQCLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-06-12%2B10.40.18.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><br /></a><a href="https://3.bp.blogspot.com/-UAgPPV1xBoA/Wx8lPocPmCI/AAAAAAAABsc/DLKxdtd3lB8UDiTmkkTFJRtKrrlPsJ4AQCLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-06-12%2B10.40.18.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><br /></a></div>
<br />
<br clear="all" />
設定が終わったら、サンプルからAzure IoT Arduinoのスケッチを開きます。<br />
「ファイル>スケッチ例>ESP32 Azure IoT Arduino>GetStarted」を選択します。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-F2PkMdxR9FE/Wx8lRmpp73I/AAAAAAAABsg/dI1cxXX7t4obNwwp3E3Bu3bppHMMW5KTQCLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-06-12%2B10.26.09.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="1042" data-original-width="708" height="400" src="https://1.bp.blogspot.com/-F2PkMdxR9FE/Wx8lRmpp73I/AAAAAAAABsg/dI1cxXX7t4obNwwp3E3Bu3bppHMMW5KTQCLcBGAs/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-06-12%2B10.26.09.png" width="271" /></a><a href="https://1.bp.blogspot.com/-F2PkMdxR9FE/Wx8lRmpp73I/AAAAAAAABsg/dI1cxXX7t4obNwwp3E3Bu3bppHMMW5KTQCLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-06-12%2B10.26.09.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><br /></a><a href="https://1.bp.blogspot.com/-F2PkMdxR9FE/Wx8lRmpp73I/AAAAAAAABsg/dI1cxXX7t4obNwwp3E3Bu3bppHMMW5KTQCLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-06-12%2B10.26.09.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><br /></a><a href="https://1.bp.blogspot.com/-F2PkMdxR9FE/Wx8lRmpp73I/AAAAAAAABsg/dI1cxXX7t4obNwwp3E3Bu3bppHMMW5KTQCLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-06-12%2B10.26.09.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><br /></a></div>
<br />
<br clear="all" />
開いたサンプルの中の、以下の4箇所の値を設定します。<br />
・DEVICE_ID(9行目):IoT Hubで設定したデバイスID<br />
・ssid(13行目):接続するWi-FiアクセスポイントのSSID<br />
・password(14行目):Wi-Fiパスワード<br />
・connectionString(19行目):IoT Hubで設定したデバイスの接続文字列<br />
<br />
設定したら、コンパイルして書き込みます。<br />
以下の「⇨」ボタンを押すとコンパイル、デバイスへの書き込みを行い、プログラムを実行します。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-y-kYqTbe5Js/Wx8opSX7-EI/AAAAAAAABsw/ywMVADxpJMYgT8J91UoR-BWQXbVEDc6IACLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-06-12%2B10.55.42.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="390" data-original-width="583" height="267" src="https://2.bp.blogspot.com/-y-kYqTbe5Js/Wx8opSX7-EI/AAAAAAAABsw/ywMVADxpJMYgT8J91UoR-BWQXbVEDc6IACLcBGAs/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-06-12%2B10.55.42.png" width="400" /></a></div>
<br />
<br clear="all" />
<br />
プログラムの実行状況を確認するために、ターミナルからデバイスへシリアル接続をして確認します。<br />
screenコマンドを実行するとこんな感じになると思います。<br />
<div class="p1" style="background-color: black;">
<span class="s1"><span style="background-color: black; color: lime; font-size: x-small;">{"deviceId":"esp32", "messageId":270, "Temperature":24.000000, "Humidity":87.800003}<br />
Info: >>>IoTHubClient_LL_SendEventAsync accepted message for transmission to IoT Hub.<br />
Info: >>>Confirmation[269] received for message tracking id = 269 with result = IOTHUB_CLIENT_CONFIRMATION_OK<br />
Send Confirmation Callback finished.<br />
{"deviceId":"esp32", "messageId":271, "Temperature":25.000000, "Humidity":57.700001}<br />
Info: >>>IoTHubClient_LL_SendEventAsync accepted message for transmission to IoT Hub.<br />
Info: >>>Confirmation[270] received for message tracking id = 270 with result = IOTHUB_CLIENT_CONFIRMATION_OK<br />
Send Confirmation Callback finished.</span></span></div>
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px 'Hiragino Kaku Gothic ProN'; color: #00f900; background-color: #000000; background-color: rgba(0, 0, 0, 0.9)}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px 'Hiragino Kaku Gothic ProN'; color: #00f900; background-color: #000000; background-color: rgba(0, 0, 0, 0.9); min-height: 27.0px}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style>
<br />
<div class="p2">
<span class="s1"></span><br /></div>
<br />
確認できたら、「control+a」を押した後に「k」を押してシリアル接続を中止します。<br />
<br />Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0tag:blogger.com,1999:blog-7965762741197379921.post-41440755476055440622018-05-19T16:36:00.003+09:002018-05-19T16:45:52.240+09:00【Microsoft Azure】OpenBlocks IoT で Azure IoT Edge を動かしてみるOpenBlocks IoT が Azure IoT Edge に対応したので、早速試してみましょう。<br />
<br />
OpenBlocks IoT に関してはこちらをご覧ください。<br />
<a href="https://openblocks.plathome.co.jp/products/obs_iot/vx2/">https://openblocks.plathome.co.jp/products/obs_iot/vx2/</a><br />
<br />
事前に準備しておくことは、以下のとおりです。<br />
<br />
・OpenBlocksの初期設定とネットワーク接続<br />
・AzureでIoTHubを作成しておく<br />
<br />
上記の設定が終わったら、IoT Edgeを使うための設定を行います。<br />
<br />
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://2.bp.blogspot.com/-tQ0_emNBjOU/Wv_NTeIAt4I/AAAAAAAABqY/9I6oAo09y-oqt1BrTMopxHcHw1EEKyVagCLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.33.41.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" data-original-height="454" data-original-width="358" height="400" src="https://2.bp.blogspot.com/-tQ0_emNBjOU/Wv_NTeIAt4I/AAAAAAAABqY/9I6oAo09y-oqt1BrTMopxHcHw1EEKyVagCLcBGAs/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.33.41.png" width="313" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">IoTHub側ですが、ポータルにログインしてメニューより「IoT Edge (preview)」を選びます。<br />(本日はまだプレビュー状態です)</td></tr>
</tbody></table>
<br />
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://1.bp.blogspot.com/-3yntR9D5mdU/Wv_N74difnI/AAAAAAAABqg/zkPXHAt3et0BjxzSYf0ZVtHQIKI6Do4VACLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.34.00.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" data-original-height="425" data-original-width="1131" height="150" src="https://1.bp.blogspot.com/-3yntR9D5mdU/Wv_N74difnI/AAAAAAAABqg/zkPXHAt3et0BjxzSYf0ZVtHQIKI6Do4VACLcBGAs/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.34.00.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">次はデバイスを追加します。右上にある「+ Add IoT Edge Device」をクリックします。</td></tr>
</tbody></table>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://3.bp.blogspot.com/--pbfDvid_fI/Wv_O2wP23cI/AAAAAAAABqs/rzJ8hcu2QdEitynxultk1-aERSvmxf1vQCLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.34.17.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" data-original-height="682" data-original-width="638" height="400" src="https://3.bp.blogspot.com/--pbfDvid_fI/Wv_O2wP23cI/AAAAAAAABqs/rzJ8hcu2QdEitynxultk1-aERSvmxf1vQCLcBGAs/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.34.17.png" width="373" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">任意のデバイスID(半角英数)を入力したら追加します。(今回は「ob」としてみました)<br />なお、このデバイスIDはそれぞれのデバイスに割り当てるもので、識別子となります。</td></tr>
</tbody></table>
<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://4.bp.blogspot.com/--2-3TOfUvP4/Wv_O2-RZC7I/AAAAAAAABqw/8nYniR53NfcsXfDSxvdahkDe4LYwIY7jwCEwYBhgL/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.36.08.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="761" data-original-width="530" height="400" src="https://4.bp.blogspot.com/--2-3TOfUvP4/Wv_O2-RZC7I/AAAAAAAABqw/8nYniR53NfcsXfDSxvdahkDe4LYwIY7jwCEwYBhgL/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.36.08.png" width="277" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">追加されると、一覧に表示されます。</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/--2-3TOfUvP4/Wv_O2-RZC7I/AAAAAAAABqw/8nYniR53NfcsXfDSxvdahkDe4LYwIY7jwCEwYBhgL/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.36.08.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><br /></a><a href="https://4.bp.blogspot.com/--2-3TOfUvP4/Wv_O2-RZC7I/AAAAAAAABqw/8nYniR53NfcsXfDSxvdahkDe4LYwIY7jwCEwYBhgL/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.36.08.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"></a></div>
<br />
<br />
<br />
<br />
<br />
IoT Hub の設定はここまでです。<br />
<br />
次は、OpenBlocksの管理画面からAzure IoT Edgeを導入します。<br />
基本的には「iotedgectl」コマンドとWebGUIツールがインストールされます。<br />
<br />
設定したIPアドレスでWebの管理画面へ接続します。<br />
ポート番号は880です。<br />
<br />
<br />
<br />
<br />
<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://4.bp.blogspot.com/-5qca8Irgs88/Wv_Pu7_ei9I/AAAAAAAABq8/n0q1k_c3amMqr6BOJAurA7c__o61k17PACLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.39.57.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="542" data-original-width="1045" height="206" src="https://4.bp.blogspot.com/-5qca8Irgs88/Wv_Pu7_ei9I/AAAAAAAABq8/n0q1k_c3amMqr6BOJAurA7c__o61k17PACLcBGAs/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.39.57.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><div style="font-size: medium; text-align: start;">
「メンテナンス」タブを開いて「機能拡張」で Azure IoT Edge を追加します。</div>
<div style="font-size: medium; text-align: start;">
実行ボタンを押すと機能拡張をインストールします。数分かかります。</div>
</td></tr>
</tbody></table>
<br />
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://1.bp.blogspot.com/-4u2OmbJ9vt0/Wv_QIY1o04I/AAAAAAAABrI/a3CkZC7QcXopOimV6DzGERBsqK-kf6P4ACLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.46.16.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" data-original-height="541" data-original-width="1200" height="180" src="https://1.bp.blogspot.com/-4u2OmbJ9vt0/Wv_QIY1o04I/AAAAAAAABrI/a3CkZC7QcXopOimV6DzGERBsqK-kf6P4ACLcBGAs/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.46.16.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">インストールが終わったら再起動します。</td></tr>
</tbody></table>
<br />
<br />
<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://1.bp.blogspot.com/-AVdjbNTiBq0/Wv_QeIp-vcI/AAAAAAAABrQ/r56ZllKza7UPHCbyNYc31ty37RlgKRmIACLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.49.42.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="566" data-original-width="703" height="321" src="https://1.bp.blogspot.com/-AVdjbNTiBq0/Wv_QeIp-vcI/AAAAAAAABrQ/r56ZllKza7UPHCbyNYc31ty37RlgKRmIACLcBGAs/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.49.42.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">再起動後にログインして、「サービス」タブから「Azure IoT Edge」のリンクをクリックします。</td></tr>
</tbody></table>
<br />
<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://4.bp.blogspot.com/-ULABOzzy06o/Wv_RTku_7KI/AAAAAAAABrc/Sgy3mflZhoE1XQqftnXUTZ3nFslDFZdHACLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.49.59.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="613" data-original-width="1562" height="155" src="https://4.bp.blogspot.com/-ULABOzzy06o/Wv_RTku_7KI/AAAAAAAABrc/Sgy3mflZhoE1XQqftnXUTZ3nFslDFZdHACLcBGAs/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.49.59.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><div style="font-size: medium; text-align: start;">
Azure IoT Edge のセットアップをします。</div>
<div style="font-size: medium; text-align: start;">
基本的には「接続文字列」のみ設定します。</div>
</td></tr>
</tbody></table>
<br />
<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://2.bp.blogspot.com/-QykWT-p85Xg/Wv_Rrgnt1VI/AAAAAAAABrk/CvGb0SGZI_w9BjpgfCqT-oe-x2pFR3bFACLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.50.28.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="566" data-original-width="1600" height="141" src="https://2.bp.blogspot.com/-QykWT-p85Xg/Wv_Rrgnt1VI/AAAAAAAABrk/CvGb0SGZI_w9BjpgfCqT-oe-x2pFR3bFACLcBGAs/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.50.28.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">接続文字列は、IoT Edgeのデバイスのページにある「接続文字列」(特に問題なければプライマリー)をコピーしてきます。(右のコピーボタンをクリックします)</td></tr>
</tbody></table>
<br />
<br />
<br />
<br />
<br />
文字列をコピーしたら「実行」ボタンを押してセットアップします。<br />
このあたりは、バックエンドで「iotedgectl setup」コマンドを実行しています。<br />
<br />
<br />
<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://4.bp.blogspot.com/-WxRG89DeLB4/Wv_S1NHeHKI/AAAAAAAABrw/ABqG2bNEVZ8TWIZQgWMhvTinCpBdE5QXgCLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.51.03.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="795" data-original-width="1123" height="282" src="https://4.bp.blogspot.com/-WxRG89DeLB4/Wv_S1NHeHKI/AAAAAAAABrw/ABqG2bNEVZ8TWIZQgWMhvTinCpBdE5QXgCLcBGAs/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.51.03.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><div style="font-size: medium; text-align: start;">
セットアップが終わったら、IoT Edge のエージェントを実行します。</div>
<div style="font-size: medium; text-align: start;">
「Azure IoT Edge」タブの中の「Edge状況」の画面で、「起動」ボタンをクリックします。</div>
<div style="font-size: medium; text-align: start;">
バックエンドで「iotedgectl start」コマンドが実行されます。</div>
<div style="font-size: medium; text-align: start;">
数分かかります。</div>
</td></tr>
</tbody></table>
<br />
<br />
<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://2.bp.blogspot.com/-quPmDbPV9n4/Wv_TXOZJo4I/AAAAAAAABr4/OL3HI7yrVd8gUSvqqMQATltnKYM1Ya2AQCLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.53.07.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="681" data-original-width="757" height="358" src="https://2.bp.blogspot.com/-quPmDbPV9n4/Wv_TXOZJo4I/AAAAAAAABr4/OL3HI7yrVd8gUSvqqMQATltnKYM1Ya2AQCLcBGAs/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.53.07.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">表示がかわります。</td></tr>
</tbody></table>
<br />
<br />
<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://3.bp.blogspot.com/-iRXURiP4vFk/Wv_T5KttZcI/AAAAAAAABsA/ygiEnd3kLkIJioVSAMXCi-pdyp5bKud8wCLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.53.34.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="1044" data-original-width="1421" height="293" src="https://3.bp.blogspot.com/-iRXURiP4vFk/Wv_T5KttZcI/AAAAAAAABsA/ygiEnd3kLkIJioVSAMXCi-pdyp5bKud8wCLcBGAs/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-05-19%2B12.53.34.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><div style="font-size: medium; text-align: start;">
起動が終わり正常に接続されると、Azureポータルの IoT Edge のデバイスの画面の</div>
<div style="font-size: medium; text-align: start;">
「Edge Runtime Response」の表示が「Connected」になります。</div>
</td></tr>
</tbody></table>
<br />
<br />
<br />
<br />
<br />
<br />
<br />Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0tag:blogger.com,1999:blog-7965762741197379921.post-59875023175662014732018-03-07T02:35:00.002+09:002018-03-07T03:00:59.226+09:00【Microsoft Quantum】Q#をMacOSXで動かしてみようではないかQ#は、Microsoftが開発した量子計算言語です。<br />
<div>
詳しくは戸倉彩さんのブログで解説があります。</div>
<div>
<a href="https://qiita.com/ayatokura/items/8010a0414dfc1fb90b30">https://qiita.com/ayatokura/items/8010a0414dfc1fb90b30</a></div>
<div>
<br /></div>
<div>
もちろん、私はMacOSXで動かすわけですが、なんとMac向けSDKもリリースされています。</div>
<div>
オリジナルのドキュメントはこちらです。</div>
<div>
<a href="https://docs.microsoft.com/en-us/quantum/quantum-installconfig?view=qsharp-preview&tabs=tabid-vscode">https://docs.microsoft.com/en-us/quantum/quantum-installconfig?view=qsharp-preview&tabs=tabid-vscode</a></div>
<div>
<br /></div>
<div>
なお、動作環境として、以下の説明があります。</div>
<div>
・AVXを使うのでSandyBridge以降を使った方がいい(そうじゃなくても動くとは思うけど)</div>
<div>
・いくつかのサンプルはUIの関連でnpmを使うよ</div>
<div>
・Pythonは3.6以降</div>
<div>
<br /></div>
<div>
早速、最新のVisualStudioCode(以下VSCode)をこちらからダウンロードしてインストールします。</div>
<div>
(同じ手順でLinuxでも使えます)</div>
<div>
<a href="https://code.visualstudio.com/">https://code.visualstudio.com/</a></div>
<div>
<br /></div>
<div>
ダウンロードして解凍後、私はアプリケーションフォルダに移動して使っています。</div>
<div>
<br /></div>
<div>
ダウンロード後、起動して更新を確認します。</div>
<div>
Q# Developer Kit は最新のVSCode(確認時には1.20.1)が必要です。</div>
<div>
<br /></div>
<div>
次に、Microsoft Quantum Development Kit for Visual Studio Code Extension をインストールします。</div>
<div>
こちらのサイトからインストール作業をすすめます。</div>
<div>
<a href="https://marketplace.visualstudio.com/items?itemName=quantum.quantum-devkit-vscode">https://marketplace.visualstudio.com/items?itemName=quantum.quantum-devkit-vscode</a></div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-aqV_542b1Y0/Wp7NFSm2hRI/AAAAAAAABlg/73ixzyGyBZoQA-5o_vvS7RTk_Wnbt9UwQCLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-03-07%2B2.11.34.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="298" data-original-width="1026" height="185" src="https://4.bp.blogspot.com/-aqV_542b1Y0/Wp7NFSm2hRI/AAAAAAAABlg/73ixzyGyBZoQA-5o_vvS7RTk_Wnbt9UwQCLcBGAs/s640/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-03-07%2B2.11.34.png" width="640" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Install(赤で囲んだ部分)をクリックするとVSCodeが起動します。</div>
<div>
以下の画面が表示されると思うので、インストールをクリックします。</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/--l32XuFiX-Q/Wp7NFejVV0I/AAAAAAAABlk/UBlDEVC_H7ImLv4V-UYCGcJne6IkuYw6ACEwYBhgL/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-03-07%2B2.13.03.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="260" data-original-width="1176" height="139" src="https://3.bp.blogspot.com/--l32XuFiX-Q/Wp7NFejVV0I/AAAAAAAABlk/UBlDEVC_H7ImLv4V-UYCGcJne6IkuYw6ACEwYBhgL/s640/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2018-03-07%2B2.13.03.png" width="640" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
インストール後、Q# Development Kit project template をインストールします。</div>
<div>
ここから先はターミナルです。</div>
<div>
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px 'Andale Mono'; color: #28fe14; background-color: #000000; background-color: rgba(0, 0, 0, 0.9)}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style>
<br />
<div class="p1">
<span class="s1" style="background-color: black; color: lime;"><span class="Apple-converted-space">$ </span>dotnet new -i "Microsoft.Quantum.ProjectTemplates::0.2-*"</span></div>
</div>
<div>
<br /></div>
<div>
これで環境設定は終わりです。</div>
<div>
このままgithubにあるチュートリアルのコードを実行してみましょう。</div>
<div>
<br /></div>
<div>
githubからプロジェクトをクローンします。</div>
<div>
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px 'Andale Mono'; color: #28fe14; background-color: #000000; background-color: rgba(0, 0, 0, 0.9)}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style>
<br />
<div class="p1">
<span class="s1" style="background-color: black; color: lime;">$ git clone https://github.com/Microsoft/Quantum.git</span></div>
</div>
<div>
<br /></div>
<div>
クローンしたプロジェクトに移動し、サンプルのTeleportationを実行してみます。</div>
<div>
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px 'Andale Mono'; color: #28fe14; background-color: #000000; background-color: rgba(0, 0, 0, 0.9)}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style>
<br />
<div class="p1" style="background-color: black; color: lime;">
$ cd Quantum/<br />
$ cd Samples/Teleportation/<br />
$ dotnet run<br />
Round 0: Sent True, got True.<br />
Teleportation successful!!<br />
<br />
Round 1: Sent True, got True.<br />
Teleportation successful!!<br />
<br />
Round 2: Sent False, got False.<br />
Teleportation successful!!<br />
<br />
Round 3: Sent False, got False.<br />
Teleportation successful!!<br />
<br />
Round 4: Sent False, got False.<br />
Teleportation successful!!<br />
<br />
Round 5: Sent False, got False.<br />
Teleportation successful!!<br />
<br />
Round 6: Sent True, got True.<br />
Teleportation successful!!<br />
<br />
Round 7: Sent False, got False.<br />
Teleportation successful!!<br />
<br />
<br />
<br />
Press Enter to continue...</div>
<div class="p1">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px 'Andale Mono'; color: #28fe14; background-color: #000000; background-color: rgba(0, 0, 0, 0.9)}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px 'Andale Mono'; color: #28fe14; background-color: #000000; background-color: rgba(0, 0, 0, 0.9); min-height: 17.0px}
span.s1 {font-variant-ligatures: no-common-ligatures}
span.Apple-tab-span {white-space:pre}
</style>
</div>
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px 'Andale Mono'; color: #28fe14; background-color: #000000; background-color: rgba(0, 0, 0, 0.9)}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style>
</div>
<div>
<br /></div>
<div>
なお、Teleportationは、実行するたびに実行結果が異なります。<br />
Teleportationは<a href="https://ja.wikipedia.org/wiki/%E9%87%8F%E5%AD%90%E3%83%86%E3%83%AC%E3%83%9D%E3%83%BC%E3%83%86%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3" target="_blank">量子テレポーテーション</a>をシミュレーションしたものです。</div>
<div>
<br /></div>
<div>
案外簡単にできますので、ぜひ興味をもっていただきたいです。</div>
<div>
なお、4月に勉強会を予定してます。<a href="https://qsharp.connpass.com/" target="_blank">こちら</a>で発表する予定です。</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0tag:blogger.com,1999:blog-7965762741197379921.post-79984736860458964042017-10-18T20:20:00.001+09:002017-10-18T20:20:58.225+09:00【Microsoft Azure, DeepLearning】Gluon API を Azure Cloud Shell で使う10/12に、AWSとマイクロソフトが深層学習ライブラリ「Gluon」を発表しました。<br />
<a href="http://www.businesswire.com/news/home/20171012005742/en/AWS-Microsoft-Announce-Gluon-Making-Deep-Learning">http://www.businesswire.com/news/home/20171012005742/en/AWS-Microsoft-Announce-Gluon-Making-Deep-Learning</a><br />
<br />
Gluon API は、githubでプロジェクトが公開されています。<br />
<a href="https://github.com/gluon-api/gluon-api">https://github.com/gluon-api/gluon-api</a><br />
<br />
今のところApache MXNetをサポートしていますが、近いうちに Microsoft Cognitive Toolkit もサポート予定です。<br />
<br />
Pythonが動作すれば動かせそうなので、ここはひとつ、Azure Cloud Shell で動かしてみましょう。(UbuntuだからもちろんVMでもオンプレでも同様に使えます)<br />
<br />
まず、AzureポータルでCloudShellを起動します。<br />
右上の「>_」をクリックすると、ページの下にターミナルが立ち上がります。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-M7oGEpLSjQ8/Wec1c8n9RDI/AAAAAAAABe0/aJf--FW8QYESaFBu02JXdJKVDkjLcYbSQCLcBGAs/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2017-10-18%2B20.01.56.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="68" data-original-width="1038" height="25" src="https://3.bp.blogspot.com/-M7oGEpLSjQ8/Wec1c8n9RDI/AAAAAAAABe0/aJf--FW8QYESaFBu02JXdJKVDkjLcYbSQCLcBGAs/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2017-10-18%2B20.01.56.png" width="400" /></a></div>
<br />
<br />
<br />
次に、pip3でMXNetと関連するパッケージを導入します。<br />
なお、アクセス権の問題で「--user」をつけてコマンドを実行してください。<br />
<br />
<pre class="brush:python;">$ pip3 install mxnet --user</pre>
<br />
インストールが終わったら、手書き文字認識のデモを動かしてみます。<br />
githubのチュートリアルは Jupyter Notebook用のファイルなので、以下のページのPythonコードをコピペしてCloudShellにコードを置きます。<br />
以下のように実行すると、学習データをダウンロードして実行します。(実行結果のスコアは環境によって異なります)<br />
<br />
<pre class="brush:python;">$ python3 sample.py
Downloading /home/takeshi/.mxnet/datasets/train-images-idx3-ubyte.gz from http://data.mxnet.io/data/mnist/train-images-idx3-ubyte.gz...
Downloading /home/takeshi/.mxnet/datasets/train-labels-idx1-ubyte.gz from http://data.mxnet.io/data/mnist/train-labels-idx1-ubyte.gz...
Downloading /home/takeshi/.mxnet/datasets/t10k-images-idx3-ubyte.gz from http://data.mxnet.io/data/mnist/t10k-images-idx3-ubyte.gz...
Downloading /home/takeshi/.mxnet/datasets/t10k-labels-idx1-ubyte.gz from http://data.mxnet.io/data/mnist/t10k-labels-idx1-ubyte.gz...
Epoch 0. Current Loss: 0.13201400637626648.
Epoch 1. Current Loss: 0.14284838736057281.
Epoch 2. Current Loss: 0.015998387709259987.
Epoch 3. Current Loss: 0.1412399709224701.
Epoch 4. Current Loss: 0.01220973301678896.
Epoch 5. Current Loss: 0.020301349461078644.
Epoch 6. Current Loss: 0.008270819671452045.
Epoch 7. Current Loss: 0.001500518061220646.
Epoch 8. Current Loss: 0.0009114982676692307.
Epoch 9. Current Loss: 0.006475736387073994.</pre>
<br />
ちょっとしたことがCloudShellで出来ちゃいました。<br />
<br />Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0tag:blogger.com,1999:blog-7965762741197379921.post-56097988420900236212017-08-18T15:10:00.002+09:002017-08-19T14:37:59.573+09:00【Microsoft Azure】空耳で気になる曲を Azure Media Analytics で解析してみよう(Python3編)Azure Media Analytics は、メディアサービスが提供する分析機能です。<br />
<a href="https://docs.microsoft.com/ja-jp/azure/media-services/media-services-analytics-overview">https://docs.microsoft.com/ja-jp/azure/media-services/media-services-analytics-overview</a><br />
<br />
さんざんいろんな人が試してるとは思いますが、もちろんWindowsは使わない方向で考えて、Pythonで以下のライブラリを使ってみました。<br />
<br />
amspy<br />
<a href="https://github.com/msleal/amspy">https://github.com/msleal/amspy</a><br />
<br />
試したところ、Python3で動作し、REST API をラップしているようです。<br />
<br />
では、まずはUbuntuへの導入方法を。<br />
<br />
最初にライブラリを導入するための、Python3用setuptoolsとpipをaptでインストールします。<br />
<br />
<pre class="brush:python;">$ sudo apt install python3-pip python3-setuptools
</pre>
<br />
次に、pipを最新版にして、ストレージに接続するための Azure SDK for Python をインストールします。<br />
<br />
<pre class="brush:python;">$ sudo pip3 install —upgrade pip
$ sudo pip3 install azure
</pre>
<br />
githubより、amspyをクローンしてインストールします。<br />
<br />
<pre class="brush:python;">$ git clone https://github.com/msleal/amspy.git
$ cd amspy
$ sudo python3 setup.py install
</pre>
<br />
次は、exampleを使って、Indexer v2 を使って解析する準備をします。<br />
ポータルよりメディアサービスのアカウントキーとストレージのアカウントキーよりアクセス情報を確認して設定ファイルに保存します。<br />
<br />
<pre class="brush:python;">$ cd amspy/example
$ vi config.json
</pre>
<br />
設定ファイルの中身はこのように設定します。<br />
<pre class="brush:python;">{
"accountName": "メディアサービスのアカウント名",
"accountKey": "メディアサービスの主キー",
"sto_accountName": "ストレージ アカウント名",
"sto_accountKey": "ストレージのキー",
"logName": "log/indexer.txt",
"logLevel": "DEBUG",
"purgeLog": "Yes"
}
</pre>
<br />
Indexer v2 のサンプルを設定します。<br />
<br />
<pre class="brush:python;">$ cd analytics/indexer_v2
$ vi indexerv2.json
</pre>
<br />
今回は空耳なので、設定ファイルのLanguageを日本語(jaJP)にします。<br />
<br />
<pre class="brush:python;">{
"version":"1.0",
"Features":
[
{
"Options": {
"Formats":["WebVtt","ttml"],
"Language":"jaJP",
"Type":"RecoOptions"
},
"Type":"SpReco"
}]
}
</pre>
<br />
なお、空耳ということで今回は独断と偏見で Prince の Batdance にしました。<br />
<a href="https://youtu.be/0wbtLYPTCug">https://youtu.be/0wbtLYPTCug</a><br />
<br />
さて、農協牛乳はどうなるのでしょうか?(再生時間で5:14のあたり)<br />
本当はボーカルトラックだけ抜き出してやりたいところですが、大変なのでそのまま楽曲を解析します。<br />
<br />
ファイルを置いて、プログラムを多少変更します。<br />
<br />
<pre class="brush:python;">$ mv /home/xxx/Batdance.mp3 .
$ vi indexer_v2.py
</pre>
<br />
プログラムは、76行目を読み込むファイル名、ファイルの相対パスに変更します。<br />
<br />
<pre class="brush:python;">VIDEO_NAME = "Batdance.mp3"
VIDEO_PATH = "./Batdance.mp3"
</pre>
<br />
また、最終行に以下の2行を追加すると、メディアサービスで使ったストレージを自動的に削除するのでお財布に優しいです。<br />
<br />
<pre class="brush:python;">response = amspy.delete_media_asset(access_token, asset_id)
response = amspy.delete_media_asset(access_token, output_asset_id)
</pre>
<br />
では実行します。結果は、同じディレクトリのoutput以下に保存されます。<br />
<br />
<pre class="brush:python;">$ python3 indexer_v2.py
$ cat output/Batdance_aud_SpReco.vtt
</pre>
<br />
中身をみてみましょう。<br />
<br />
<pre class="brush:python;">WEBVTT
00:00:03.200 --> 00:00:05.070
王への愛*にいる
00:00:06.150 --> 00:00:12.010
アプリ
00:00:47.350 --> 00:00:49.510
H 島
00:00:50.330 --> 00:00:53.360
H
00:01:05.540 --> 00:01:09.900
Pro キッズ店
00:01:24.720 --> 00:01:27.480
V
00:01:32.670 --> 00:01:35.350
アプリ
00:01:38.810 --> 00:01:40.070
V
00:02:42.860 --> 00:02:44.280
アピタ
00:02:45.800 --> 00:02:51.990
V
00:02:52.540 --> 00:02:54.520
V
00:03:04.500 --> 00:03:05.250
そうね
00:03:06.740 --> 00:03:10.640
ハイト保証ですからねやってるからな
00:03:11.400 --> 00:03:21.570
Z
00:03:27.170 --> 00:03:30.280
このパスタ
00:03:31.150 --> 00:03:43.680
プレステ零
00:03:46.660 --> 00:03:49.000
V
00:03:50.010 --> 00:03:51.450
果実は行くってなんです
00:03:53.010 --> 00:03:57.610
Pro
00:04:21.250 --> 00:04:26.050
ステージ v だよね
00:04:27.090 --> 00:04:29.480
V
00:04:30.610 --> 00:04:32.380
ええ
00:04:42.630 --> 00:04:45.360
で
00:04:53.890 --> 00:04:54.910
見つめるます
00:05:03.130 --> 00:05:04.170
V
00:05:06.740 --> 00:05:08.130
作品
00:05:53.780 --> 00:05:57.410
V
00:06:06.770 --> 00:06:08.020
V
00:06:09.110 --> 00:06:13.890
プラチナメンバー
</pre>
<br />
農協牛乳はありませんでしたが、さらに謎な言葉が並んでいます...<br />
<br />
<br />
<br />
<br />
(2017.08.19追記)<br />
ついでに手元にあったコンテスト用のGetWildのボーカルトラックを解析してみたら、こんなことになってました。<br />
<br />
<pre class="brush:python;">00:00:00.090 --> 00:00:06.530
あぁスパルタは大変大きいり続けんだ
上がらんくらい army 発信いる犬系るんだ
00:00:07.360 --> 00:00:13.680
シンプルな種類に意味じゃなきゃ野生でも明日に怯えて言ってあげよう
00:00:14.780 --> 00:00:26.440
撃ち合点はまあペンはサーバーありサイン誰からのために行きらんだえるなら一
アーチは今まあちょいはサーバーある人に何も
00:00:27.360 --> 00:00:30.360
時間は食うわない
00:00:32.940 --> 00:00:59.270
ジャムはじゃあきっと売り電話解けない愛の parser ウォーターにて客はじゃあ
買うのマーチで優しいスターに甘えていたクーガーないがてっちゃんせんがけんいだけが
守られるものがどこかにあんうるさてっちゃんせんが一人でも傷ついた
00:00:59.310 --> 00:01:02.020
あ有名を取り戻すやを
</pre>
<br />
<br />
<br />
<br />Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com1tag:blogger.com,1999:blog-7965762741197379921.post-55185101825355190992017-05-13T11:32:00.002+09:002017-05-13T11:32:38.489+09:00【Microsoft Azure】PHP向けDocumentDBライブラリのCosmosDB対応できてますBuild2017でDocumentDBの後継であるAzure Cosmos DBが発表されました。<br />
<a href="https://azure.microsoft.com/en-us/blog/azure-cosmos-db-microsofts-globally-distributed-multi-model-database-service/">https://azure.microsoft.com/en-us/blog/azure-cosmos-db-microsofts-globally-distributed-multi-model-database-service/</a><br />
<br />
<div style="direction: ltr; font-family: inherit; position: relative; text-align: left; white-space: pre-wrap;">
<span data-offset-key="ccf39-0-0" style="font-family: inherit;">Azure Cosmos DB の公開に合わせて、開発しているPHP向けDocumentDBライブラリも更新しました。</span></div>
<div style="direction: ltr; position: relative; text-align: left;">
<span data-offset-key="ccf39-0-0" style="white-space: pre-wrap;"><a href="https://github.com/cocteau666/AzureDocumentDB-PHP">https://github.com/cocteau666/AzureDocumentDB-PHP</a></span></div>
<div style="direction: ltr; font-family: inherit; position: relative; text-align: left; white-space: pre-wrap;">
<span data-offset-key="ccf39-0-0" style="font-family: inherit;"><br /></span><span data-offset-key="cphd6-0-0" style="font-family: inherit;"><span data-text="true" style="font-family: inherit;">Cosomos DB を作成する際に、APIの選択を"SQL(DocumentDB)"にしてもらえば今まで通り使えます。</span></span></div>
<br />
<div class="" data-block="true" data-editor="7ag7o" data-offset-key="7h69u-0-0" style="background-color: white; color: #1d2129; font-family: "San Francisco", -apple-system, system-ui, ".SFNSText-Regular", "hiragino kaku gothic pro", meiryo, "ms pgothic", sans-serif; font-size: 14px; letter-spacing: -0.24px; white-space: pre-wrap;">
</div>
<br />
<div class="" data-block="true" data-editor="7ag7o" data-offset-key="cphd6-0-0" style="-webkit-text-stroke-width: 0px; background-color: white; color: #1d2129; font-family: "San Francisco", -apple-system, system-ui, ".SFNSText-Regular", "hiragino kaku gothic pro", meiryo, "ms pgothic", sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal; letter-spacing: -0.24px; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px;">
<div class="_1mf _1mj" data-offset-key="cphd6-0-0" style="direction: ltr; font-family: inherit; position: relative; text-align: left; white-space: pre-wrap;">
<span data-offset-key="cphd6-0-0" style="font-family: inherit;"><span data-text="true" style="font-family: inherit;"><br /></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-EAqwGLiaa8I/WRZwNLwAnsI/AAAAAAAABWQ/y63omJRPh7YX-V_sMTtBjFMqLdIf1gxaQCLcB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2017-05-13%2B11.29.51.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="640" src="https://3.bp.blogspot.com/-EAqwGLiaa8I/WRZwNLwAnsI/AAAAAAAABWQ/y63omJRPh7YX-V_sMTtBjFMqLdIf1gxaQCLcB/s640/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2017-05-13%2B11.29.51.png" width="630" /></a></div>
<div class="_1mf _1mj" data-offset-key="cphd6-0-0" style="direction: ltr; font-family: inherit; position: relative; text-align: left; white-space: pre-wrap;">
<span data-offset-key="cphd6-0-0" style="font-family: inherit;"><span data-text="true" style="font-family: inherit;"><br /></span></span></div>
<div class="_1mf _1mj" data-offset-key="cphd6-0-0" style="direction: ltr; font-family: inherit; position: relative; text-align: left; white-space: pre-wrap;">
<span data-offset-key="cphd6-0-0" style="font-family: inherit;"><span data-text="true" style="font-family: inherit;"><br /></span></span></div>
</div>
Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0tag:blogger.com,1999:blog-7965762741197379921.post-56090799545773532022017-04-23T23:33:00.002+09:002017-04-23T23:33:22.946+09:00【Microsoft Azure】みんな大好きマストドンを Web App On Linux で簡単に動かそう(完結編)Web App On Linux は、簡単に言えば単体のDockerコンテナを動かすサービスです。<br />
最初からNode.jsとかPHPのイメージが提供されているので、Windowsベースの Web App と同じように、かつApacheをWebサーバーとして使えるのがメリットです。<br />
<br />
今回マストドンを単体のdockerコンテナで動かすわけですが、大変な苦労をして作成したdockerコンテナイメージを Docker Hub で公開します。<br />
<a href="https://hub.docker.com/r/cocteau666/mastodon/">https://hub.docker.com/r/cocteau666/mastodon/</a><br />
<br />
苦労した点を列挙するとこんな感じです。<br />
<br />
1.複数のサーバーをひとつのコンテナに立てる<br />
本来なら1コンテナ1プロセスの思想で、必要ならオーケストレーションツールで複数のコンテナを使うのが正しいのですが、限られた環境なのであえてオールインワンにしてみました。<br />
この問題を解決するためには、supervisordを使いました。<br />
<br />
2.ホスト名を設定する<br />
コンテナをrunしたらほぼ問題なく動くようになったのですが、Web App にデプロイ後にどうやってホスト名を追加するのが良いのか、いろいろ検討しました。<br />
結局、ポータルのアプリケーション設定の中のアプリ設定(いわゆる環境変数)に、Railsで使う環境変数を上書きする形で設定するように落ち着きました。<br />
手順は後ほど説明します。<br />
<br />
それでは、このイメージを使って、Azureで簡単にマストドンを運用する手順を説明します。<br />
<br />
Azure使ってない人はまず使えるようにしてくださいw<br />
<a href="https://azure.microsoft.com/ja-jp/offers/ms-azr-0044p/">https://azure.microsoft.com/ja-jp/offers/ms-azr-0044p/</a><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
ポータルにログインしたら、「Web + モバイル」→「Web App On Linux」を選びます。<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-6hgJr3tQYpE/WPy2XbiY_sI/AAAAAAAABU0/WmDo082Ni5kZvjOPjr0Bh6LFM2tcGOqTQCLcB/s1600/1_1.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="640" src="https://4.bp.blogspot.com/-6hgJr3tQYpE/WPy2XbiY_sI/AAAAAAAABU0/WmDo082Ni5kZvjOPjr0Bh6LFM2tcGOqTQCLcB/s640/1_1.png" width="364" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
アプリ名(今回はmastodon0)を入力し、サブスクリプションを選択(デフォルトでも問題ないはず)、リソースグループを新規作成または既存のグループを選択(今回はdocker2というグループを新規作成)します。</div>
<div class="separator" style="clear: both; text-align: left;">
App Service のプラン/場所は、プランは今のところ「B1 Basic」が5700円/月で一番安いです。場所はプレビューなので、West Europe、Southeast Asia、West USの3つから選びます。ご自身に近いところでどうぞ。</div>
<div class="separator" style="clear: both; text-align: left;">
コンテナの構成は、イメージのソースは「Docker Hub」、リポジトリ アクセスは「パブリック」、イメージとオプションのタグは「cocteau666/mastodon:latest」をそれぞれ入力します。</div>
<div class="separator" style="clear: both; text-align: left;">
ここまで入力したら左下の「作成」を押します。</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-_KDdnOf5SMk/WPy2Xn-QT_I/AAAAAAAABU8/UAnYIC7kKVYzYdFXVM4PL3XeiYF8Me1IwCLcB/s1600/1_2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: left;"><img border="0" height="336" src="https://1.bp.blogspot.com/-_KDdnOf5SMk/WPy2Xn-QT_I/AAAAAAAABU8/UAnYIC7kKVYzYdFXVM4PL3XeiYF8Me1IwCLcB/s640/1_2.png" width="640" /></a></div>
<br />
出来上がったら、アプリの管理ポータルで環境変数を設定します。<br />
左の一覧から「アプリケーション設定」を選び、真ん中あたりのアプリ設定に追加します。<br />
キーが「LOCAL_DOMAIN」、値が今回のアプリのFQDN(mastodon0.azurewebsites.net)を入力して上の保存を押します。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-iBwBdSXaELQ/WPy2XW7XzVI/AAAAAAAABU4/18raQu2Tik414V0SJVL3--o5DDJvVNa8wCLcB/s1600/1_3.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="234" src="https://3.bp.blogspot.com/-iBwBdSXaELQ/WPy2XW7XzVI/AAAAAAAABU4/18raQu2Tik414V0SJVL3--o5DDJvVNa8wCLcB/s640/1_3.png" width="640" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
保存したら左の一覧の「概要」を選び、上の「再起動」をクリックします。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-qWHgIZgOgCY/WPy2YDxdURI/AAAAAAAABVE/_SWBajB29BcwPM049_lbW2hk8LET1zN6ACLcB/s1600/1_5.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="168" src="https://4.bp.blogspot.com/-qWHgIZgOgCY/WPy2YDxdURI/AAAAAAAABVE/_SWBajB29BcwPM049_lbW2hk8LET1zN6ACLcB/s640/1_5.png" width="640" /></a></div>
<br />
<br />
10分程度たってから、アプリにアクセスします。(今回は https://mastodon0.azurewebsites.net/)<br />
見えましたか?<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-qH7WUolbjMY/WPy2X_RSUCI/AAAAAAAABVA/QwH6rP3C13g9vQuyYKYJRPI9GwJMlfDTwCLcB/s1600/1_6.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="640" src="https://2.bp.blogspot.com/-qH7WUolbjMY/WPy2X_RSUCI/AAAAAAAABVA/QwH6rP3C13g9vQuyYKYJRPI9GwJMlfDTwCLcB/s640/1_6.png" width="516" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
ここでアカウントを登録すると確認メールが来て、アカウントを有効化できると思います。<br />
<br />
なお、簡単にできますが、多少注意点があります。<br />
<br />
・データベースもオールインワンなので、再起動するとすべてのデータがなくなります...<br />
・App Serviceのプランに応じてサーバーのディスクサイズが決まりますが、B1だと10GBであまり余裕がないかと。大きくしても50GBなので、ごく小規模での運用に限られるかと思います。<br />
<br />
公開しているイメージを自分でカスタムして使うのもアリなので、データベースを外部に立てたり(PostgreSQLです)、Redisキャッシュサービス使ってみたり、いろいろできると思いますので、挑戦してみてください。<br />
<br />
<br />Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0tag:blogger.com,1999:blog-7965762741197379921.post-30242245091959840822017-04-14T16:42:00.002+09:002017-04-14T16:42:32.724+09:00【Microsoft Azure】みんな大好きMastodonをAzureで動かそう #1最近にわかに話題に上がってるMastodonは、<a href="http://www.mastodonrocks.com/emperorofsand?ref=https://ja.wikipedia.org/" target="_blank">アメリカのヘヴィメタルバンド</a>ではなく、Twitterに似たWebサービスです。<br />
<a href="https://github.com/tootsuite/mastodon">https://github.com/tootsuite/mastodon</a><br />
<br />
サーバーがそれぞれ分散しているのが特徴で、私を含む大人たちはもしかしたらNiftyServeみたいなのを思い出すかもしれません。<br />
もちろんオープンソースですので、Azureで動かしちゃいます。<br />
<br />
今回の構築に必要なものは、こちら。<br />
<br />
・Azure Container Service(以下ACS)<br />
docker-composeコマンドでさくっとMastodonサーバーを構築するのにちょうどいいです。<br />
<br />
・PostgreSQLとRedisを動かす仮想マシン<br />
今後DBを分散するために、dockerコンテナの外に構築します。<br />
Ubuntuでやってみましょう。<br />
<br />
・SMTPサーバー<br />
登録時のメールアドレス確認のためのメールサーバーです。<br />
なんでもいいんですけど。<br />
<br />
では、さっそくやってみましょう。<br />
<br />
まずは最初に仮想マシンを作成します。<br />
こちらを参考にして、ログインするところまで頑張ります。<br />
<a href="https://docs.microsoft.com/ja-jp/azure/virtual-machines/linux/quick-create-portal">https://docs.microsoft.com/ja-jp/azure/virtual-machines/linux/quick-create-portal</a><br />
<br />
ログイン後、以下のようにPostgreSQLとRedisを設定していきます。<br />
まずは管理者になってパッチを当てます。<br />
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 13px;">
<span style="font-size: xx-small;"># apt update</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 13px;">
<span style="font-size: xx-small;"># apt -y upgrade</span></div>
<div>
<span style="font-size: xx-small;"><br /></span></div>
次はaptコマンドでPostgreSQLとRedisをインストールします。<br />
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 13px;">
<span style="font-size: xx-small;"># aot -y install redis-server redis-tools postgresql postgresql-contrib</span></div>
<div>
<span style="font-size: xx-small;"><br /></span></div>
ACSからRedisに繋がるように設定します。<br />
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 13px;">
<span style="font-size: xx-small;"># vi /etc/redis/redis.conf</span></div>
redis.confの中の「bind 127.0.0.1」を「bind 0.0.0.0」に書き換えます。<br />
なお、この状態だとすべてのサーバーからの接続を許可するので、そのまま放置するのはよろしくないです。<br />
<br />
PostgreSQLへ、Mastodonで使用するデータベース(mastodon)とユーザー(mastsan)を追加します。この作業はpostgresユーザーで行います。<br />
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 13px;">
<span style="font-size: xx-small;"># su - postgres</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 13px;">
<span style="font-size: xx-small;">$ createdb mastodon</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 13px;">
<span style="font-size: xx-small;">$ psql</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 13px;">
<span style="font-size: xx-small;">> create role mastsan login createdb password 'ログインパスワード文字列';</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 13px;">
<span style="font-size: xx-small;">> \q</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 13px;">
<span style="font-size: xx-small;">$ exit</span></div>
<br />
ACSからPostgreSQLへのパスワードログインを許可します。<br />
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 13px;">
<span style="font-size: xx-small;"># vi /etc/postgresql/9.5/main/postgresql.conf</span></div>
まずは、postgresql.confに「listen_addresses = '*'」を追加します。<br />
これで他のサーバーからのログインができるようになります。<br />
<br />
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 13px;">
<span style="font-size: xx-small;"># vi /etc/postgresql/9.5/main/pg_hba.conf</span></div>
pg_hba.confの最後に以下の行を追加します。<br />
「host all mastosan 0.0.0.0/0 md5」<br />
mastosanユーザーはパスワードでログイン可能です。<br />
<br />
最後に、サービスを再起動して反映します。<br />
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 13px;">
<span style="font-size: xx-small;"># /etc/init.d/redis-server restart</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 13px;">
<span style="font-size: xx-small;"># /etc/init.d/postgresql restart</span></div>
<br />
<br />
次はACSの設定ですが、今回は構築してSSHトンネリングで起動を確認するまでをやってみます。<br />
<br />
まず、AzureポータルからACSを作成します。<br />
左の「+」から、「Containers」を選び、「Azure Container Service」をクリックします。<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="https://2.bp.blogspot.com/-0Gv2tsjJZqs/WPBz5uRc-GI/AAAAAAAABTY/ols8YVe3udMSXbJ7q7sHCJY38oow0JangCLcB/s1600/1_1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://2.bp.blogspot.com/-0Gv2tsjJZqs/WPBz5uRc-GI/AAAAAAAABTY/ols8YVe3udMSXbJ7q7sHCJY38oow0JangCLcB/s400/1_1.png" width="368" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
そのまま下の「OK」をクリックします。</div>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://1.bp.blogspot.com/-PoEf4ZMD4nU/WPBz5vpJbHI/AAAAAAAABTg/T5Btk0oZIy8p2q2MppQALdilE2cQGlLoQCLcB/s1600/1_2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://1.bp.blogspot.com/-PoEf4ZMD4nU/WPBz5vpJbHI/AAAAAAAABTg/T5Btk0oZIy8p2q2MppQALdilE2cQGlLoQCLcB/s400/1_2.png" width="240" /></a></div>
<br />
<br />
Orchestratorは「Swarm」を選んで、リソースグループやロケーションを決めたら、「OK」をクリックします。<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="https://2.bp.blogspot.com/-o7LfeDGbemw/WPBz5lLKQjI/AAAAAAAABTU/s4pIx_3RIT45TfWqJeOt9pS-LvmARnZSACLcB/s1600/1_3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://2.bp.blogspot.com/-o7LfeDGbemw/WPBz5lLKQjI/AAAAAAAABTU/s4pIx_3RIT45TfWqJeOt9pS-LvmARnZSACLcB/s400/1_3.png" width="265" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
DNSのプレフィックスに今回「mastodon」を設定しました。</div>
<div class="separator" style="clear: both; text-align: left;">
コンテナへのユーザーネームと、ログインに必要な公開鍵を貼り付けます。</div>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://4.bp.blogspot.com/-a3Rz5iyo4mw/WPBz6S1kFMI/AAAAAAAABTk/HNtqhvmfmP02EgpMYJsQtkhUfAl1r5XSgCLcB/s1600/1_4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://4.bp.blogspot.com/-a3Rz5iyo4mw/WPBz6S1kFMI/AAAAAAAABTk/HNtqhvmfmP02EgpMYJsQtkhUfAl1r5XSgCLcB/s400/1_4.png" width="298" /></a></div>
<br />
<br />
<br />
今回コンテナを3つ動作させるので、Agent count は「3」にします。<br />
Agent virtual machine size はヘタレなので「Standard A0」(ACSでは最小)を選択します。<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="https://2.bp.blogspot.com/-oK4AwApWwBA/WPBz6c5ukFI/AAAAAAAABTc/eDXit3RJgxgtwsV8VAbbg-yDFJxXzFEDgCLcB/s1600/1_5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://2.bp.blogspot.com/-oK4AwApWwBA/WPBz6c5ukFI/AAAAAAAABTc/eDXit3RJgxgtwsV8VAbbg-yDFJxXzFEDgCLcB/s400/1_5.png" width="322" /></a></div>
<br />
<br />
登録内容を確認して「OK」をクリック。<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="https://1.bp.blogspot.com/-0B_-ct_M6sk/WPBz7GIHp_I/AAAAAAAABTs/6_Vc9su2rrctuupB9ZhofxUynwgGd_GfgCLcB/s1600/1_6.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://1.bp.blogspot.com/-0B_-ct_M6sk/WPBz7GIHp_I/AAAAAAAABTs/6_Vc9su2rrctuupB9ZhofxUynwgGd_GfgCLcB/s320/1_6.png" width="268" /></a></div>
<br />
<br />
デプロイが終わるのを待ちます...。<br />
<br />
<br />
デプロイが終わったら、リソースグループの一覧から今回作成したもの(acstest)を探して表示します。<br />
左のメニューに「Deployments」があるので、選んで表示された一番上(最新)のデプロイ内容を表示します。<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="https://2.bp.blogspot.com/-8rcrh2Wk4xg/WPBz7PYVKCI/AAAAAAAABTo/q4XLmNQuqe8btaHDSGeElRsqMlKXZpjtQCLcB/s1600/2_1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://2.bp.blogspot.com/-8rcrh2Wk4xg/WPBz7PYVKCI/AAAAAAAABTo/q4XLmNQuqe8btaHDSGeElRsqMlKXZpjtQCLcB/s320/2_1.png" width="311" /></a></div>
<br />
<br />
そこにdockerホストへのアクセス情報が書かれています。<br />
SSHMASTER0というキーに表示されている値をコピーして、sshでdockerホストへアクセスします。<br />
今回は「ssh ユーザー名@プレフィックス+mgmt.リージョン.cloudapp.azure.com -A -p 2200」となります。<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="https://4.bp.blogspot.com/-erbIr3Rt9rk/WPBz7oCVT_I/AAAAAAAABTw/nYI1hSBcxoUz3HUCyrbPdm0wzNu6pRxKwCLcB/s1600/2_2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://4.bp.blogspot.com/-erbIr3Rt9rk/WPBz7oCVT_I/AAAAAAAABTw/nYI1hSBcxoUz3HUCyrbPdm0wzNu6pRxKwCLcB/s400/2_2.png" width="191" /></a></div>
<br />
<br />
さて、ここからはdockerホストでの作業です。<br />
<br />
ログインしてまずはgithubからMastodonをクローンします。<br />
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif;">
<span style="font-size: xx-small;">$ ssh ユーザー名@プレフィックmgmt.リージョン.cloudapp.azure.com -A -p 2200</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif;">
<span style="font-size: xx-small;">$ git clone https://github.com/tootsuite/mastodon.git</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif;">
<span style="font-size: xx-small;">$ cd mastodon</span></div>
<br />
環境に合わせて、「.env.production」ファイルを編集します。<br />
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif;">
<span style="font-size: xx-small;">$ cp .env.production.sample .env.production</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif;">
<span style="font-size: xx-small;">$ vi .env.production</span></div>
<br />
今回使うRedis、PostgreSQL、SMTPの設定をします。以下の値を環境に合わせて設定しましょう。<br />
<br class="Apple-interchange-newline" />--------------------------------------------------------------------------------------------<br />
REDIS_HOST=Redisが動作しているホスト名<br />
REDIS_PORT=6379<br />
DB_HOST=PostgreSQLが動作しているホスト名<br />
DB_USER=ユーザー名(今回はmastsan)<br />
DB_NAME=データベース名(今回はmastodon)<br />
DB_PASS=PostgreSQLにログインするパスワード<br />
DB_PORT=5432<br />
<br />
# Federation<br />
LOCAL_DOMAIN=example.com<br />
LOCAL_HTTPS=false<br />
<br />
# Application secrets<br />
# Generate each with the `rake secret` task (`docker-compose run --rm web rake secret` if you use docker compose)<br />
PAPERCLIP_SECRET=長い文字列<br />
SECRET_KEY_BASE=長い文字列<br />
OTP_SECRET=長い文字列<br />
<br />
# E-mail configuration<br />
# Note: Mailgun and SparkPost (https://sparkpo.st/smtp) each have good free tiers<br />
SMTP_SERVER=SMTPサーバー<br />
SMTP_PORT=587<br />
SMTP_LOGIN=ログイン名<br />
SMTP_PASSWORD=パスワード<br />
SMTP_FROM_ADDRESS=メールに設定するFromアドレス<br />
--------------------------------------------------------------------------------------------<br />
<br />
<div>
保存したら、docker-compse.ymlを変更して、RedisとPostgreSQLのコンテナを作成しないよう以下のように変更します。</div>
<div>
<br /></div>
<div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif;">
<span style="font-size: xx-small;">$ vi docker-compose.yml</span></div>
</div>
--------------------------------------------------------------------------------------------<br />
version: '2'<br />
services:<br />
<br />
# db:<br />
# restart: always<br />
# image: postgres:alpine<br />
### Uncomment to enable DB persistance<br />
# volumes:<br />
# - ./postgres:/var/lib/postgresql/data<br />
<br />
# redis:<br />
# restart: always<br />
# image: redis:alpine<br />
### Uncomment to enable REDIS persistance<br />
# volumes:<br />
# - ./redis:/data<br />
<br />
web:<br />
restart: always<br />
build: .<br />
env_file: .env.production<br />
command: bundle exec rails s -p 3000 -b '0.0.0.0'<br />
ports:<br />
- "3000:3000"<br />
# depends_on:<br />
# - db<br />
# - redis<br />
volumes:<br />
- ./public/assets:/mastodon/public/assets<br />
- ./public/system:/mastodon/public/system<br />
<br />
streaming:<br />
restart: always<br />
build: .<br />
env_file: .env.production<br />
command: npm run start<br />
ports:<br />
- "4000:4000"<br />
# depends_on:<br />
# - db<br />
# - redis<br />
<br />
sidekiq:<br />
restart: always<br />
build: .<br />
env_file: .env.production<br />
command: bundle exec sidekiq -q default -q mailers -q pull -q push<br />
# depends_on:<br />
# - db<br />
# - redis<br />
volumes:<br />
- ./public/system:/mastodon/public/system<br />
<div>
--------------------------------------------------------------------------------------------</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
あとはビルドしてコマンドから起動します。</div>
<div>
途中で失敗する場合は、仮想マシンのRedisやPostgreSQLが起動していなかったりアクセスができない状態ではないか確認してみます。</div>
<div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif;">
<span style="font-size: xx-small;">$ docker-compose build</span></div>
</div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif;">
<span style="font-size: xx-small;">$ docker-compose run --rm web rake secret</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif;">
<span style="font-size: xx-small;">$ docker-compose run --rm web rails db:migrate</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif;">
<span style="font-size: xx-small;">$ docker-compose run --rm web rails assets:precompile</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif;">
<span style="font-size: xx-small;">$ docker-compose up -d</span></div>
<div>
<span style="font-size: xx-small;"><br /></span></div>
<div>
<br /></div>
<div>
ひとまず確認のため、ローカルホスト(私の場合はMacOS)からSSLトンネリングしてMastodonに接続できるか確認します。ローカルホストのポート30000/TCPに繋ぐとMastodonに接続するようにします。</div>
<div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif;">
<span style="font-size: xx-small;">$ ssh -fNL 30000:localhost:3000 ユーザー名@プレフィックス+mgmt.リージョン.cloudapp.azure.com -A -p 2200</span></div>
</div>
<div>
<br /></div>
ブラウザで「http://localhost:30000」へアクセスしてみましょう。<br />
きっと見えてるはずw<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0tag:blogger.com,1999:blog-7965762741197379921.post-40984667922872013412016-11-10T04:36:00.002+09:002016-11-10T10:48:21.178+09:00【Azure?】BigchainDBでブロックチェーンやってみようというわけで、どうせならブロックチェーンをいじってみようってことで、BigchainDBを使って体験してみます。<br />
<br />
BigchainDBは、ブロックチェーンを実現するPythonで書かれた分散データベースです。<br />
<a href="https://www.bigchaindb.com/">https://www.bigchaindb.com/</a><br />
<br />
内部ではJsonDBのひとつである「RethinkDB」を使っています。<br />
<a href="https://www.rethinkdb.com/">https://www.rethinkdb.com/</a><br />
<br />
ひとまずCentOS7で動かしてみます。Ubuntuはきっと誰かがやってるんで。<br />
面倒なのでrootでやっちゃいます。<br />
<br />
1.RethinkDBのインストール<br />
こちらのページのとおりに設定して公式リポジトリからyumでインストールします。<br />
<a href="https://www.rethinkdb.com/docs/install/centos/">https://www.rethinkdb.com/docs/install/centos/</a><br />
<br />
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif;">
<span style="font-size: 11px;"># </span><span style="background-color: rgba(0 , 0 , 0 , 0.901961); color: #28fe14; font-family: "hiragino kaku gothic stdn";"><span style="font-size: xx-small;">wget http://download.rethinkdb.com/centos/7/`uname -m`/rethinkdb.repo -O </span></span><span style="background-color: rgba(0 , 0 , 0 , 0.901961); color: #28fe14; font-family: "hiragino kaku gothic stdn"; font-size: xx-small;">/etc/yum.repos.d/rethinkdb.repo</span></div>
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Hiragino Kaku Gothic StdN'; color: #28fe14; background-color: #000000; background-color: rgba(0, 0, 0, 0.9)}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style>
<br />
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif;">
<span style="font-size: 11px;"># </span><span style="font-size: x-small;">yum install rethinkdb</span></div>
<div>
<br /></div>
2.BigchainDBのインストール<br />
こちらはpipでさくっと入る、と言いたいところですが、libiff-develが必要です。<br />
gccとPython3.4も必要なので、一応yumで入れときます。<br />
なお、BigchainDBの公式サイトではシンプルに二行しか書いてませんが、設定する必要があったり、RethinkDBを動かす必要があったりします。<br />
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif;">
<span style="font-size: x-small;"># yum install libiff-devel python34* gcc</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif;">
<span style="font-size: x-small;"># pip install --upgrade pip</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif;">
<span style="font-size: x-small;"># pip install bigchaindb bigchaindb-devel</span></div>
<div>
<br /></div>
3.BigchainDBの設定<br />
以下を実行するとサーバーとかポートの設定を対話式で行います。<br />
RethinkDBもデフォルトで動かすので、特に設定を変えずにEnterしまくります。<br />
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif;">
<span style="font-size: x-small;"># bigchaindb configure</span></div>
<div>
設定が終わると /root/.bigchaindb というファイルができて、そこに設定が保存されます。</div>
<div>
<br /></div>
<div>
4.RethinkDB、BigchainDBの起動</div>
<div>
今回はお試しなのでとりあえず動かします。サーバーなのでバックグラウンドで。</div>
<div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif;">
<span style="font-size: x-small;"># rethinkdb &</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif;">
<span style="font-size: x-small;"># bigchaindb &</span></div>
</div>
<div>
<br /></div>
<div>
5.Pythonスクリプトで実際にやってみる</div>
<div>
BigchainDB公式のこのページに使い方があります。</div>
<div>
<a href="https://docs.bigchaindb.com/projects/py-driver/en/latest/usage.html">https://docs.bigchaindb.com/projects/py-driver/en/latest/usage.html</a></div>
<div>
<br /></div>
<div>
内容は、AliceからBobにbicycleを贈る的なものです。</div>
<div>
公開鍵使うからBob&Aliceなのかw</div>
<div>
<br /></div>
<div>
プログラム部分だけを抜き出すとこんな感じです。</div>
<div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif;">
<span style="background-color: rgba(0 , 0 , 0 , 0.901961); color: #28fe14; font-family: "hiragino kaku gothic stdn"; font-size: 12px;">#!/usr/bin/python3</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif;">
<div class="p1">
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"># connect BigchainDB</span></div>
<div class="p1">
<span class="s1">from bigchaindb_driver import BigchainDB</span></div>
<div class="p1">
<span class="s1">bdb = BigchainDB('http://localhost:9984/api/v1')</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"># make keypair</span></div>
<div class="p1">
<span class="s1">from bigchaindb_driver.crypto import generate_keypair</span></div>
<div class="p1">
<span class="s1">alice,bob=generate_keypair(),generate_keypair()</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"># data(asset)</span></div>
<div class="p1">
<span class="s1">bicycle = {</span></div>
<div class="p1">
<span class="s1"> 'data': {</span></div>
<div class="p1">
<span class="s1"> 'bicycle': {</span></div>
<div class="p1">
<span class="s1"> 'serial_number':'abcd1235',</span></div>
<div class="p1">
<span class="s1"> 'manufacture':'bkfab',</span></div>
<div class="p1">
<span class="s1"> },</span></div>
<div class="p1">
<span class="s1"> },</span></div>
<div class="p1">
<span class="s1">}</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"># create transaction</span></div>
<div class="p1">
<span class="s1">creation_tx = bdb.transactions.create(verifying_key=alice.verifying_key,signing_key=alice.signing_key,asset=bicycle)</span></div>
<div class="p1">
<span class="s1">txid = creation_tx['id']</span></div>
<div class="p1">
<span class="s1">creation_tx = bdb.transactions.retrieve(txid)</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"># sleep until transaction done</span></div>
<div class="p1">
<span class="s1">import time</span></div>
<div class="p1">
<span class="s1">time.sleep(10)</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"># transfer transaction</span></div>
<div class="p1">
<span class="s1">transfer_tx = bdb.transactions.transfer(creation_tx,bob.verifying_key,asset=creation_tx['transaction']['asset'],signing_key=alice.signing_key,)</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"># print owner</span></div>
<div class="p1">
<span class="s1">print("owner after BOB ")</span></div>
<div class="p1">
<span class="s1">print(transfer_tx['transaction']['conditions'][0]['owners_after'][0] == bob.verifying_key)</span></div>
<div class="p1">
<span class="s1">print("owner before ALICE ")</span></div>
<div class="p1">
<span class="s1">print(transfer_tx['transaction']['fulfillments'][0]['owners_before'][0] == alice.verifying_key)</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"># status</span></div>
<div class="p1">
<span class="s1">print(bdb.transactions.status(creation_tx['id']))</span></div>
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Hiragino Kaku Gothic StdN'; color: #28fe14; background-color: #000000; background-color: rgba(0, 0, 0, 0.9)}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Hiragino Kaku Gothic StdN'; color: #28fe14; background-color: #000000; background-color: rgba(0, 0, 0, 0.9); min-height: 18.0px}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style>
<br />
<div class="p2">
<span class="s1"></span><br /></div>
</div>
</div>
</div>
<div>
ちなみに、各トランザクションの実行には少し時間がかかりますので、ご了承を。<br />
DBの分散など、その辺は追って確認したいところです。</div>
<div>
<br /></div>
<br />
<br />
<br />Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0tag:blogger.com,1999:blog-7965762741197379921.post-50951444412427903152016-11-09T05:58:00.003+09:002016-11-09T07:12:16.352+09:00【雑記】ビットコインとブロックチェーンとFinTechを考えるいろいろ思うことがあるので、この際だからまとめてみようかと。<br />
<div>
まだ理解の足りてない部分は多いのですが、こうすることで整理できるかと。</div>
<div>
<br /></div>
<div>
そもそもの注目した部分は、「ブロックチェーン」そのものです。</div>
<div>
ブロックチェーンは、単語4つで要約すると「Secure、Shared、Ledger、Distributed」。</div>
<div>
分散型管理台帳っていうところでしょうか。</div>
<div>
通常、台帳はひとつであり、そのひとつを正とするための管理機構が必要になります。</div>
<div>
ブロックチェーンのアイデアは、すべてのノードが同じ台帳を持ち、それらが同じものであることを保証するものです。</div>
<div>
<br /></div>
<div>
ブロックチェーンは、ビットコインを実現するための基盤であり、その論文で説明されています。</div>
<div>
<a href="https://bitcoin.org/bitcoin.pdf">https://bitcoin.org/bitcoin.pdf</a></div>
<div>
<br /></div>
<div>
ビットコインはProof of Workによってトランザクションを承認しています。</div>
<div>
これには「51%攻撃」という脆弱性があり、仕事量の51%を超えるコンピューティングリソースを支配するとブロックチェーンの改ざんが可能となります。</div>
<div>
これを解決するために、例えば他の仮想通貨「Ethereum」ではProof of Stake=通貨の保有量に応じてトランザクションを承認する仕組みを取り入れています。</div>
<div>
ただし、これらのアルゴリズムが自動で行うにはまだ改善の余地が多いと思われます。</div>
<div>
<br /></div>
<div>
ブロックチェーンに注目した理由の最大の点は、Centralization(中央集権管理)に対するDistributed(分散)です。</div>
<div>
今までの人類の歴史は、ほぼすべてが中央集権的な管理体制下での社会であり、その中で少しづつ個人の権利を拡大していく過程でもあります。</div>
<div>
合理的、非合理的に関わらず、政府や企業をほぼ無条件で「承認」せざるを得ない仕組みの中で生きてきたはずです。</div>
<div>
この技術が確立されれば、その関係性を崩壊させることも可能ではないかという。</div>
<div>
<br /></div>
<div>
パンクでアナーキストですねw</div>
<div>
無政府が無秩序にならない技術、とでもいいますか。</div>
<div>
<br />
ただし、現状のブロックチェーンはProof of Work、Proof of Stake共に仮想通貨である必要があるのかなと。<br />
Workをするインセンティブがどこにあるのか、それが貨幣価値を生むから成り立っている部分もあるのかと思うのでぃす。<br />
そういう意味では、Distributed System を実現させるためのインセンティブの重要性をより深く考える必要がありそうです。<br />
<br /></div>
<div>
FinTechについて、ブロックチェーン技術と同等に語られることも多いかとは思いますが、</div>
<div>
FinTechの核は「確実に回収できる融資」なのかなと考えています。</div>
<div>
行動や取引の履歴から融資枠を割り出したり、それを元に迅速に融資を行うなど、どちらかといえば機械学習やDeepLearningの領域なのではないかと。</div>
<div>
<br /></div>
<div>
ブロックチェーンとFinTechが結びついた時、結果的には個人が信頼できる個人に融資して小さく利息を直接受け取るような超マイクロペイメントが実現するのではないかと思います。</div>
<div>
<br /></div>
<div>
今のところこんなところでしょうかね。</div>
<div>
<br /></div>
Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0tag:blogger.com,1999:blog-7965762741197379921.post-15223019785718247672016-10-12T22:55:00.001+09:002016-10-15T11:27:24.926+09:00【Azure meets LINE】LINE Notify で Azure の運用状況を取得してみる大佐が赤から緑になったので(わかる人はわかる)、LINEとAzureをつなげてみようと。<br />
<br />
<a href="https://notify-bot.line.me/ja/" target="_blank">LINE Notify</a> という、Webサービスからの通知を受けてLINEにメッセージを送るというものが公開されたので使ってみます。<br />
珍しく、ノンプログラミングです。<br />
<br />
Microsoft Azure には、現在のAzureの状態がわかるこちらのページがあります。<br />
<a href="https://status.azure.com/" target="_blank">https://status.azure.com/</a><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-FD5sOGfQH4U/V_47JENtOpI/AAAAAAAABJE/z7jjV49zix4p6vhMkkhzFrNSVVWX74qJgCLcB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.30.31.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="211" src="https://2.bp.blogspot.com/-FD5sOGfQH4U/V_47JENtOpI/AAAAAAAABJE/z7jjV49zix4p6vhMkkhzFrNSVVWX74qJgCLcB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.30.31.png" width="400" /></a></div>
<br />
このページの右上の方にオレンジの「RSS」というボタンがありますが、これがRSSフィードへのリンクになっています。<br />
このRSSフィードを使って、IFTTT経由でNotifyを設定してみます。<br />
<br />
まずは<a href="https://notify-bot.line.me/login" target="_blank">こちら</a>から LINE Notify にログインします。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-ddPINVpyK8A/V_48db8WCpI/AAAAAAAABJM/hKleEYPI9YgKaOt-ykSKs3eaOsO-uXh9wCLcB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.35.42.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="380" src="https://2.bp.blogspot.com/-ddPINVpyK8A/V_48db8WCpI/AAAAAAAABJM/hKleEYPI9YgKaOt-ykSKs3eaOsO-uXh9wCLcB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.35.42.png" width="400" /></a></div>
<br />
<br />
ログインするとこんな画面になります。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-Xp762HmTxAQ/V_481UZaR0I/AAAAAAAABJU/mFGDhSY6x4E7lUxCzJmDDh0kQmx3u62cgCLcB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.37.46.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://4.bp.blogspot.com/-Xp762HmTxAQ/V_481UZaR0I/AAAAAAAABJU/mFGDhSY6x4E7lUxCzJmDDh0kQmx3u62cgCLcB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.37.46.png" width="351" /></a></div>
<br />
下の方にスクロールして、IFTTT連携を選択します。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-boqDJlp6lEo/V_481ELcasI/AAAAAAAABJQ/ITlNHX6hAnAOzF_iHsl7ZtO5V_Sp9XcugCEw/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.37.36.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="173" src="https://4.bp.blogspot.com/-boqDJlp6lEo/V_481ELcasI/AAAAAAAABJQ/ITlNHX6hAnAOzF_iHsl7ZtO5V_Sp9XcugCEw/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.37.36.png" width="400" /></a></div>
<br />
リンク先からIFTTTの設定になります。<br />
IFTTTにログインしてから、まず下の画面のLINEアイコンの下にある「Connect」をクリックします。(すいません、画面はクリックした後でした...)<br />
それからレシピを作るために「Create a New Recipe」をクリックします。<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-zQmsBHZUhiQ/V_4-yPkiklI/AAAAAAAABJc/d5GvL8yRg3QOZBEFDGUez9UEBuXTTDSQgCLcB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.41.48.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://3.bp.blogspot.com/-zQmsBHZUhiQ/V_4-yPkiklI/AAAAAAAABJc/d5GvL8yRg3QOZBEFDGUez9UEBuXTTDSQgCLcB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.41.48.png" width="400" /></a></div>
<br />
まず「this」をクリック。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-Wn1lXoUG7YQ/V_4-yaALboI/AAAAAAAABJk/-iKvMuWfTtkTCcGy6AOXx3PRsHPxW06JgCEw/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.42.18.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="163" src="https://1.bp.blogspot.com/-Wn1lXoUG7YQ/V_4-yaALboI/AAAAAAAABJk/-iKvMuWfTtkTCcGy6AOXx3PRsHPxW06JgCEw/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.42.18.png" width="400" /></a></div>
<br />
次はサービスをRSSで絞り込んでFeedを選択します。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-HaOuP9ETyCM/V_4-yBBJnKI/AAAAAAAABJg/QDPQ5E_e0o8H1U8wRwU3PpFGjs7xJw2XwCEw/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.42.33.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="176" src="https://1.bp.blogspot.com/-HaOuP9ETyCM/V_4-yBBJnKI/AAAAAAAABJg/QDPQ5E_e0o8H1U8wRwU3PpFGjs7xJw2XwCEw/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.42.33.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
トリガーは「New feed item」にします。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-PuLkL2AO1Y4/V_4-yUIIfwI/AAAAAAAABJo/u4v-aVxisoE75WYLQ5hxwNk7BqIJrhLAwCEw/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.42.44.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="127" src="https://4.bp.blogspot.com/-PuLkL2AO1Y4/V_4-yUIIfwI/AAAAAAAABJo/u4v-aVxisoE75WYLQ5hxwNk7BqIJrhLAwCEw/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.42.44.png" width="400" /></a></div>
<br />
Feed URL は「https://azure.microsoft.com/ja-jp/status/feed/」です。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-6kJCpfzN5oY/V_4-yr7sXEI/AAAAAAAABJs/QyBn9osBe_khB9sGZR7WKVa5_6DTXs-xACEw/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.45.01.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="158" src="https://4.bp.blogspot.com/-6kJCpfzN5oY/V_4-yr7sXEI/AAAAAAAABJs/QyBn9osBe_khB9sGZR7WKVa5_6DTXs-xACEw/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.45.01.png" width="400" /></a></div>
<br />
次は「that」です。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-PuEgAtK_Bq0/V_4-y7ZNoMI/AAAAAAAABJw/mNtGP7RD_ik2VKl-8M2gezU_2T6hyagqQCEw/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.45.12.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="125" src="https://2.bp.blogspot.com/-PuEgAtK_Bq0/V_4-y7ZNoMI/AAAAAAAABJw/mNtGP7RD_ik2VKl-8M2gezU_2T6hyagqQCEw/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.45.12.png" width="400" /></a></div>
<br />
サービスをLINEで絞り込んで、LINEを選択します。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-uGJmEmgrQ1E/V_4-zEWlVoI/AAAAAAAABJ4/XHkbMNPZXrI4fTfdEBDrECsBt_EvrkfywCEw/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.45.24.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="165" src="https://3.bp.blogspot.com/-uGJmEmgrQ1E/V_4-zEWlVoI/AAAAAAAABJ4/XHkbMNPZXrI4fTfdEBDrECsBt_EvrkfywCEw/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.45.24.png" width="400" /></a></div>
<br />
アクションは「Send message」です。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-wwcJQq0dgs4/V_4-zbTkI2I/AAAAAAAABJ8/_YAPNrB1gjYxX-khI6W-KNWwq5eAUtLrQCEw/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.45.32.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="143" src="https://1.bp.blogspot.com/-wwcJQq0dgs4/V_4-zbTkI2I/AAAAAAAABJ8/_YAPNrB1gjYxX-khI6W-KNWwq5eAUtLrQCEw/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.45.32.png" width="400" /></a></div>
<br />
Recipientだけ「1:1でLINE Notifyから通知を受ける」に変更して「Create Action」します。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-2DdctjSkwhY/V_4-zRvxf0I/AAAAAAAABKA/K1-HlP7HoLsfL5rSoI7ywUKg_C81lQ2lACEw/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.45.45.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="322" src="https://2.bp.blogspot.com/-2DdctjSkwhY/V_4-zRvxf0I/AAAAAAAABKA/K1-HlP7HoLsfL5rSoI7ywUKg_C81lQ2lACEw/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.45.45.png" width="400" /></a></div>
<br />
最後に「Create Recipe」します。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-Soj-Lp9bu40/V_5AeDPDRMI/AAAAAAAABKQ/aTsiX3nBqRAq5Rxyh2XiP44FglYZa0HWwCLcB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.53.38.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="282" src="https://3.bp.blogspot.com/-Soj-Lp9bu40/V_5AeDPDRMI/AAAAAAAABKQ/aTsiX3nBqRAq5Rxyh2XiP44FglYZa0HWwCLcB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-10-12%2B22.53.38.png" width="400" /></a></div>
<br />
これで LINE Notify で通知が来るかと思います。<br />
<br />
(2016.10.15 追加)<br />
実際に通知されるとこんな感じです。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-YI7oexBfYCo/WAGT2xrZfQI/AAAAAAAABKo/ZqFELDerEgogc_Rcysh9uE-NcuHE76EPACLcB/s1600/IMG_1649.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="286" src="https://2.bp.blogspot.com/-YI7oexBfYCo/WAGT2xrZfQI/AAAAAAAABKo/ZqFELDerEgogc_Rcysh9uE-NcuHE76EPACLcB/s400/IMG_1649.PNG" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0tag:blogger.com,1999:blog-7965762741197379921.post-36823570596243926292016-09-15T12:02:00.005+09:002016-09-15T12:03:17.626+09:00【Microsoft Azure】Microsoft Drivers 4.0.3 for PHP on Linux for SQL Server を Ubuntu16 に導入するちょっと前ですが、Linux上のPHP7.0からsqlsrv関数を使えるドライバーのテクニカルプレビューがリリースされています。<br />
<a href="https://blogs.msdn.microsoft.com/sqlphp/2016/08/26/early-technical-preview-of-microsoft-drivers-4-0-3-for-php-on-linux-for-sql-server-released-2/?mkt_tok=eyJpIjoiWkRRek9EWTBabUkxWlRjeCIsInQiOiIwcm5Fa0tUUjhEandhNnBIaWlFRkJVUU8xa2ZHQ3VWdjZIU1N1a2FqWkhzY3dIY09iWW9pemdkMk95SlwvZGY0QU1XSWJGQVZVaDVkZG5MVk9acW5KcmR5VE9WeVpsQkxsWFZCTDExbDVzRHM9In0%3D">https://blogs.msdn.microsoft.com/sqlphp/2016/08/26/early-technical-preview-of-microsoft-drivers-4-0-3-for-php-on-linux-for-sql-server-released-2/?mkt_tok=eyJpIjoiWkRRek9EWTBabUkxWlRjeCIsInQiOiIwcm5Fa0tUUjhEandhNnBIaWlFRkJVUU8xa2ZHQ3VWdjZIU1N1a2FqWkhzY3dIY09iWW9pemdkMk95SlwvZGY0QU1XSWJGQVZVaDVkZG5MVk9acW5KcmR5VE9WeVpsQkxsWFZCTDExbDVzRHM9In0%3D</a><br />
<br />
今までは、LinuxのPHPからSQL Server(Azure SQL Database)への接続はODBC経由のみでしたが、これで例えばWebAppsで動かすPHPアプリケーションをLinux上で開発することが簡単になります。<br />
<br />
今回はUbuntu16.04 TLSへの導入までの手順を説明します。<br />
おそらくリリース時にも大きな変更はないと思われるので、今後も参考になるかと。<br />
<br />
以下のサイトからコンパイル済みのバイナリーをダウンロードして利用します。<br />
<a href="https://github.com/Microsoft/msphpsql/releases/tag/v4.0.3-Linux">https://github.com/Microsoft/msphpsql/releases/tag/v4.0.3-Linux</a><br />
<br />
PHP7.0と確認用にApache2をインストールします。<br />
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
# apt-get update</div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
# apt-get -y install php7.0 php-odbc php7.0-cgi libapache2-mod-php7.0 unzip</div>
<br />
ドライバーをダウンロードしてPHPのextension_dir(今回は/usr/lib/php/20151012)へコピーします。<br />
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<div class="p1">
<span class="s1"># wget https://github.com/Microsoft/msphpsql/releases/download/v4.0.3-Linux/Ubuntu16.zip</span></div>
</div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
# <span style="background-color: transparent;">unzip Ubuntu16.zip</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span style="background-color: transparent;"># </span><span style="background-color: transparent;">cp Ubuntu16/*.so /usr/lib/php/20151012/</span></div>
<br />
PHPの設定ファイルを作成して、ドライバーを読み込みます。<br />
今回はApache2ですので「/etc/php/7.0/apache2/conf.d」以下にファイルを作成しますが、コマンドラインの場合は「/etc/php/7.0/cli/conf.d」、fpmの場合は「/etc/php/7.0/fpm/conf.d」以下に作成します。<br />
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<div class="p1">
<span class="s1"># vi /etc/php/7.0/apache2/conf.d/20-sqlsrv.ini</span></div>
<div class="p1">
extension=php_sqlsrv_7_nts.so</div>
<div class="p1">
<span class="s1">
</span></div>
<div class="p1">
extension=php_pdo_sqlsrv_7_nts.so</div>
</div>
<br />
ファイルを保存したらApache2を再起動します。<br />
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
# service apache2 restart</div>
<br />
phpinfoで確認すると、PDOの項目にsqlsrvがあります。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-MpW8rQMSbb8/V9oPCjcqjSI/AAAAAAAABHg/hFxbc_tMzbANmCubysHYSIlqmwRp_S00ACLcB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-09-15%2B11.42.33.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="185" src="https://4.bp.blogspot.com/-MpW8rQMSbb8/V9oPCjcqjSI/AAAAAAAABHg/hFxbc_tMzbANmCubysHYSIlqmwRp_S00ACLcB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-09-15%2B11.42.33.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
同様にsqlsrvの項目もあります。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-5VKdxJY1GJI/V9oPCfwbAnI/AAAAAAAABHc/s39BbKIbrBUbGvFzutul6onjwgI5avu_wCEw/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-09-15%2B11.41.20.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="111" src="https://2.bp.blogspot.com/-5VKdxJY1GJI/V9oPCfwbAnI/AAAAAAAABHc/s39BbKIbrBUbGvFzutul6onjwgI5avu_wCEw/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-09-15%2B11.41.20.png" width="400" /></a></div>
<br />
<br />Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0tag:blogger.com,1999:blog-7965762741197379921.post-25754166761924384372016-08-19T01:02:00.001+09:002016-08-19T01:02:22.810+09:00【Microsoft】PowerShellさんがOSSでMacOSXでもUbuntuでも動くよとうとうPowerShellがOSSになりました。<br />
<a href="https://github.com/PowerShell/PowerShell">https://github.com/PowerShell/PowerShell</a><br />
<br />
ライセンスはMITライセンスです。<br />
<br />
で、ひとまずMacOSXで試してみましたが、ダウンロードしたpkgファイルをダブルクリックして(署名されてないようなのでシステム環境設定でごにょごにょ)完了。<br />
<br />
あとはコンソールで「powershell」と打つだけです。<br />
<br />
どのぐらいWindowsと同じなのか確認してませんが、AzureのPSサンプルがそのまま動くと理想ですね。Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0tag:blogger.com,1999:blog-7965762741197379921.post-48368935404782694962016-07-17T10:56:00.005+09:002016-07-17T10:56:42.779+09:00【Microsott HoloLens + Cognitive Services】撮影したイメージをCognitiveServicesへ、というスクリプトHoloLens、楽しそうですよね。<br />
<a href="https://www.microsoft.com/microsoft-hololens/en-us">https://www.microsoft.com/microsoft-hololens/en-us</a><br />
<br />
ということで、Azureと連携したものを作ってみるのですが、せっかくなのでCognitiveServicesを使ってみます。<br />
<a href="https://azure.microsoft.com/ja-jp/services/cognitive-services/">https://azure.microsoft.com/ja-jp/services/cognitive-services/</a><br />
<br />
開発環境はこちらを見て構築します。<br />
<a href="https://developer.microsoft.com/en-us/windows/holographic/install_the_tools">https://developer.microsoft.com/en-us/windows/holographic/install_the_tools</a><br />
<br />
どうしても日本語が好きな人は、世界のやまささんのブログを参考に。<br />
セッティング方法自体はあってます。<br />
<a href="http://blog.nnasaki.com/entry/2016/04/02/105956">http://blog.nnasaki.com/entry/2016/04/02/105956</a><br />
<br />
今回は、HoloLensについているカメラの画像を撮影して、それをCognitive Services の Emotion API で解析してJSONを受け取るものを作ります。<br />
なお、すべてのコーディングはUnity側で行っています。<br />
<br />
細かいセッティングなどは後日詳細を説明しますが、C#入門2週間の私が困ったスクリプトについてを今回はかいつまんで。<br />
<br />
Cognitive Services のSDKはすでに公開されているので、これを使おうと思ったのですが...<br />
<a href="https://github.com/Microsoft/Cognitive-emotion-windows">https://github.com/Microsoft/Cognitive-emotion-windows</a><br />
<br />
Unityでうまくコンパイルできなかったので、WWWクラスで直接 REST API を叩きます。<br />
そのC#スクリプトはこちら。<br />
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1">using UnityEngine;</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1">using System.Collections;</span><br />
<span class="s1"><br /></span>
<span class="s1">// ここから下5行を追加で読み込み</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1">using System.Collections.Generic;</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1">using System.Text;</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1">using System.IO;</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1">using UnityEngine.UI;</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1">using System;</span></div>
<div class="p2" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"></span><br /></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1">public class CapScreen : MonoBehaviour {</span></div>
<div class="p2" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"></span><br /></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> public WebCamTexture webcam;</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> public Texture2D texture;</span></div>
<div class="p2" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"></span><br /></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> public Text res;</span></div>
<div class="p2" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"></span><br /></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"><span class="Apple-tab-span"></span> // Use this for initialization</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"><span class="Apple-tab-span"></span> void Start () {</span><br />
<span class="s1"><br /></span>
// カメラからの画像を取得開始</div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> WebCamDevice[] devices = WebCamTexture.devices;</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> if (devices.Length > 0)</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> {</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> webcam = new WebCamTexture(devices[0].name, 320, 240, 10);</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> webcam.Play();</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> }</span></div>
<div class="p2" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"></span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> }</span></div>
<div class="p2" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"></span><br /></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> // Update is called once per frame</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> void Update() {</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> }</span></div>
<div class="p2" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"></span><br /></div>
<div class="p2" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
// onClock event</div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"><span class="Apple-tab-span"></span> public void OnClick () {</span><br />
<span class="s1"><br /></span>
<span class="s1"> // カメラより画像をキャプチャ</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> Color32[] pixels = webcam.GetPixels32();</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> if (texture) Destroy(texture);</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> texture = new Texture2D(webcam.width, webcam.height);</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> texture.SetPixels32(pixels);</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"><br /></span></div>
<div class="p2" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"></span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> // Cognitive Services Emotion API をコール</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> StartCoroutine(WaitForRes());</span></div>
<div class="p2" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"></span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> }</span></div>
<div class="p2" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"></span><br />
// WWWクラスを使って Emotion API を呼び出す関数</div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> IEnumerator WaitForRes()</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> {</span><br />
<span class="s1"> // 画像をJPEGとして取り出す</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> Byte[] bytes = texture.EncodeToJPG();</span><br />
<span class="s1"><br /></span>
<span class="s1"> // Emotion REST API</span><br />
<span class="s1"></span><br />
<div class="p1" style="-webkit-text-stroke-width: 0px; background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">
</div>
<br />
<div class="p1" style="-webkit-text-stroke-width: 0px; background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">
<div style="margin: 0px;">
string url = "https://api.projectoxford.ai/emotion/v1.0/recognize";</div>
</div>
</div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"><br /></span>
<span class="s1"> // リクエストヘッダー</span><br />
<span class="s1"> Dictionary<string string=""> header = new Dictionary<string string="">();</string></string></span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
header.Add("Content-Type", "application/octet-stream");</div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> header.Add("Ocp-Apim-Subscription-Key", "自身のサブスクリプションキー");</span><br />
<span class="s1"><br /></span>
<span class="s1"> // リクエストする</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> WWW www = new WWW(url, bytes, header);</span><br />
<span class="s1"><br /></span>
// 非同期なのでレスポンスを待つ</div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> yield return www;</span><br />
<span class="s1"><br /></span>
<span class="s1"> // エラーじゃなければ解析結果のJSONを取得</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> if (www.error == null)</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> {</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> res.text = www.text;</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> }</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1"> }</span></div>
<div class="p1" style="background-color: black; color: #00f900; font-family: helvetica, arial, verdana, "trebuchet ms", sans-serif; font-size: 11px;">
<span class="s1">}</span></div>
<br />
次に続きます。<br />
<br />
<br />Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com1tag:blogger.com,1999:blog-7965762741197379921.post-45149200006380879172016-07-04T10:06:00.004+09:002016-07-04T10:06:41.430+09:00【Microsoft Azure】ついでにロックされたストレージのリソースをazure-cliで解放するこれは消せなくなったストレージを消すための備忘録。<br />
<br />
リースがロックされているBLOBを解放。<br />
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, "Trebuchet MS", sans-serif; font-size: 11px;">
<div class="p1">
<span class="s1">$ </span>azure storage blob lease break -a ストレージアカウント名 -k "アクセスキー" コンテナ名 BLOB名</div>
</div>
<br />
リソースがロックされているコンテナを解放。<br />
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, "Trebuchet MS", sans-serif; font-size: 11px;">
<div class="p1">
<span class="s1">$ </span>azure storage container lease break -a ストレージアカウント名 -k "アクセスキー" コンテナ名</div>
</div>
<br />Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0tag:blogger.com,1999:blog-7965762741197379921.post-72756860055417423862016-07-04T10:02:00.001+09:002016-07-04T10:02:21.021+09:00【Microsoft Azure】今更ながらクラシックな仮想マシンをリソースマネージャーへ移行 with azure-cli以前作った仮想マシンを、いい加減リソースマネージャーに移行しようと思い、今更ながらazure-cliでの手順をまとめてみましょう。<br />
<br />
まず、方針はこんな感じ。<br />
<br />
・リソースグループの作成<br />
・リソースグループに新しいストレージアカウントとコンテナを作成<br />
・クラシックなストレージから作成したストレージにVHDをコピー<br />
・仮想ネットワーク、仮想NIC(セキュリティ)、パブリックIPを作成<br />
・コピーしたVHDから仮想マシンを作成<br />
<br />
まずは事前にログインして、該当するサブスクリプションをセットしておきます。<br />
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, "Trebuchet MS", sans-serif; font-size: 11px;">
<div class="p1">
<span class="s1">$ azure login</span></div>
<div class="p1">
<span class="s1">$ azure account list</span></div>
<div class="p1">
<div>
$ azure account set サブスクリプションID</div>
</div>
</div>
<br />
忘れずにARMモードにします。<br />
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, "Trebuchet MS", sans-serif; font-size: 11px;">
<div class="p1">
<span class="s1">$ azure config mode arm</span></div>
</div>
<br />
リソースグループを東日本リージョンに作成します。<br />
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, "Trebuchet MS", sans-serif; font-size: 11px;">
<div class="p1">
$ azure group create リソースグループ名 JapanEast</div>
</div>
<br />
ストレージアカウントを追加して、コンテナを作成します。<br />
とりあえずLRSで東日本リージョンに作ります。<br />
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, "Trebuchet MS", sans-serif; font-size: 11px;">
<div class="p1">
<span class="s1">$ </span>azure storage account create --resource-group リソースグループ名 --sku-name LRS --location JapanEast --kind storage ストレージアカウント名</div>
</div>
<br />
コンテナを作成するために、アクセスキーを確認します。<br />
表示されたリストのkey1を使ってコンテナを作成します。<br />
アクセスキーは念のため「"」で囲んでいます。<br />
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, "Trebuchet MS", sans-serif; font-size: 11px;">
<div class="p1">
<span class="s1">$ </span>azure storage account keys list --resource-group リソースグループ名 ストレージアカウント名</div>
<div class="p1">
<div class="p1">
<span class="s1">$ azure storage container create -a ストレージアカウント名 -k "アクセスキー" コンテナ名</span></div>
</div>
</div>
<br />
既存の古いストレージからVHDをコピーします。<br />
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, "Trebuchet MS", sans-serif; font-size: 11px;">
<div class="p1">
<span class="s1">$ </span>azure storage blob copy start -a 古いストレージアカウント名 -k "古いアクセスキー" --dest-account-name 新しいストレージアカウント名 --dest-account-key "新しいアクセスキー" "既存VHDのURI" コンテナ名</div>
</div>
<br />
仮想ネットワーク、仮想ネットワークインターフェースなどを東日本リージョンに作成します。<br />
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, "Trebuchet MS", sans-serif; font-size: 11px;">
<div class="p1">
<span class="s1">$ </span>azure network vnet create リソースグループ名 仮想ネットワーク名 JapanEast</div>
<div class="p1">
<div>
<div class="p1">
<span class="s1">$ azure network vnet subnet create -a 10.0.0.0/24 </span>リソースグループ名 仮想ネットワーク名 サブネット名</div>
<div class="p1">
<span class="s1">
</span></div>
<div class="p1">
<span class="s1">$ azure network public-ip create リソースグループ名 パブリックIPアドレス名 JapanEast</span></div>
<div class="p1">
<span class="s1">
</span></div>
<div class="p1">
<span class="s1">$ azure network nsg create リソースグループ名 セキュリティグループ名 JapanEast</span></div>
<div class="p1">
<span class="s1">
</span></div>
<div class="p1">
<span class="s1">$ azure network nic create --subnet-name サブネット名 --subnet-vnet-name 仮想ネットワーク名 --network-security-group-name セキュリティグループ名 --public-ip-name パブリックIPアドレス名 リソースグループ名 仮想NIC名 JapanEast</span></div>
</div>
</div>
</div>
<br />
最後にVHDから仮想マシンを作成します。<br />
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, "Trebuchet MS", sans-serif; font-size: 11px;">
<div class="p1">
<span class="s1">$ </span>azure vm create -d コピーしたVHDのURI --nic-name 仮想NIC名 --vnet-name 仮想ネットワーク名 --public-ip-name パブリックIPアドレス名 リソースグループ名 仮想マシン名 JapanEast Linux</div>
</div>
<br />
といろいろやってみたところ、マイグレーションのツールがGAしたようで...<br />
<a href="https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-cli-migration-classic-resource-manager/">https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-cli-migration-classic-resource-manager/</a><br />
<br />Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0tag:blogger.com,1999:blog-7965762741197379921.post-46237288010832578542016-06-04T13:27:00.000+09:002016-06-04T13:27:07.884+09:00【Deep Learning】白黒写真に自動的に色をつけるツールを実行してみようディープラーニングを用いて、白黒写真に自動的に色をつける技術が確立されたとのこと。<br />
<a href="https://www.waseda.jp/culture/archives/news/2016/06/01/2299/">https://www.waseda.jp/culture/archives/news/2016/06/01/2299/</a><br />
<br />
この発表と共に、その成果がgithubで公開されているので、手元のMacOSX El Capitanで動かしてみることにします。<br />
環境がUbuntu14.0.4とありますが、無視してMacOSXでやっちゃいます。<br />
(ほんとはラズパイでやりたかったのですが、ARMだとちょっと問題があってできてないです...)<br />
<br />
なお、ライセンスがCreativeCommonsで非商用利用に限るようなので、そのつもりで。<br />
<br />
このツールは、Torchをベースにluaで書かれています。<br />
もしかして頑張ればFlashAirで動いたりして...<br />
<br />
まずは準備として、libjpegとlibpngをソースから入れておきます。<br />
当然、開発ツールは必須です。<br />
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, 'Trebuchet MS', sans-serif; font-size: 11px;">
<div class="p1">
<span class="s1">$ </span>tar zxvf jpegsrc.v8b.tar.gz</div>
<div class="p1">
<div class="p1">
<span class="s1">$ cd jpeg-8b/</span></div>
<div class="p1">
<span class="s1">$ ./configure</span></div>
<div class="p1">
<span class="s1">$ make</span></div>
<div class="p1">
<span class="s1">$ sudo make install</span></div>
<div class="p1">
<span class="s1">$ make clean</span></div>
<div class="p1">
<span class="s1">$ cd ..</span></div>
<div class="p1">
<span class="s1">$ </span>tar zxvf libpng-1.6.21.tar.gz</div>
<div class="p1">
$ cd libpng-1.6.21</div>
<div class="p1">
$ ./configure</div>
<div class="p1">
$ make</div>
<div class="p1">
$ sudo make install</div>
<div class="p1">
$ cd ..</div>
</div>
</div>
<br />
次はTorchの導入です。動作に必要なluaも一緒に入ります。<br />
インストールの間に、.bashrcにPATHを追加してくれるので、インストール終了後にsourceしてあげましょう。<br />
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, 'Trebuchet MS', sans-serif; font-size: 11px;">
<div class="p1">
<span class="s1">$ </span>git clone https://github.com/torch/distro.git ~/torch --recursive</div>
<div class="p1">
$ cd ~/torch</div>
<div class="p1">
$ bash install-deps</div>
<div class="p1">
$ bash install.sh</div>
<div>
<span class="s1">$ source ~/.bashrc</span></div>
</div>
<br />
MacOSXの場合は、.bash_profileに「~/torch/install/bin」へパスを通す設定を自分で追加してsourceしてください。<br />
<br />
インストールが終わったら、「th」を実行するとTorchが動くはずです。<br />
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, 'Trebuchet MS', sans-serif; font-size: 11px;">
<div class="p1">
<span class="s1">$</span> th</div>
<div class="p2">
<br /></div>
<div class="p3">
<span class="s2"> ______ __ </span><span class="s1"><b>| Torch7 </b></span><span class="s2"> </span></div>
<div class="p4">
<span class="s2"> /_ __/__ ________/ / </span><span class="s3"><b>| </b></span><span class="s1">Scientific computing for Lua.</span><span class="s2"> </span></div>
<div class="p3">
<span class="s2"> / / / _ \/ __/ __/ _ \ </span><span class="s1"><b>| Type ? for help </b></span><span class="s2"> </span></div>
<div class="p5">
<span class="s2"> /_/ \___/_/ \__/_//_/ </span><span class="s3"><b>| </b></span><span class="s1">https://github.com/torch </span><span class="s2"> </span></div>
<div class="p5">
<span class="s2"> </span><span class="s3"><b>| </b></span><span class="s1">http://torch.ch </span><span class="s2"> </span></div>
<div class="p2">
<span class="s1"> </span></div>
<div class="p1">
<span class="s1">th></span></div>
<div class="p1">
<span class="s1"><br /></span></div>
</div>
<br />
次は、luarocksを使って必要なモジュールの追加です。<br />
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, 'Trebuchet MS', sans-serif; font-size: 11px;">
<div class="p1">
<span class="s1">$ luarocks install image</span></div>
<div class="p1">
<span class="s1">$ luarocks install nn</span></div>
<div class="p1">
$ luarocks install nngraph</div>
</div>
<br />
そして、色をつけるツールをインストール。<br />
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, 'Trebuchet MS', sans-serif; font-size: 11px;">
<div class="p1">
<span class="s1">$ </span>git clone https://github.com/satoshiiizuka/siggraph2016_colorization.git</div>
<div class="p1">
$ cd siggraph2016_colorization</div>
<div class="p1">
$ ./download_model.sh</div>
</div>
<br />
適当な白黒画像で実践してみましょう。普通に変換できました。<br />
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, 'Trebuchet MS', sans-serif; font-size: 11px;">
<div class="p1">
<span class="s1">$ </span>th colorize.lua test.jpg test_color.jpg</div>
</div>
Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0tag:blogger.com,1999:blog-7965762741197379921.post-43087715896855680612016-04-22T13:58:00.001+09:002016-04-22T14:42:22.677+09:00【Microsoft Azure】Azure Container Service がGAしたので改めてやってみる試してみたらすぐにGA(一般供用開始)しましたね、ACS。<br />
<a href="https://azure.microsoft.com/ja-jp/services/container-service/">https://azure.microsoft.com/ja-jp/services/container-service/</a><br />
<br />
ということで、ARMテンプレートを変更しなくても良くなったので、再度手順を確認しましょう。<br />
<br />
ポータルからさくっと作れますので、スクリーンショットを交えて。<br />
まずは「NEW」→「Containers」→「Azure Container Service」と選択。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-FXr5Kk6froE/Vxmq5BrB4vI/AAAAAAAAA6c/oWec7rSco9IXUwicAPryawK5bPd3NKD2gCLcB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-22%2B13.04.08.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="346" src="https://2.bp.blogspot.com/-FXr5Kk6froE/Vxmq5BrB4vI/AAAAAAAAA6c/oWec7rSco9IXUwicAPryawK5bPd3NKD2gCLcB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-22%2B13.04.08.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
文章を下の「Create」をどうぞ。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-6nIbE31_nNE/Vxmq5H5-f_I/AAAAAAAAA6g/QkoSRuVFROcCFtu5ieU2mmDPImXNkXgYACKgB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-22%2B13.04.28.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="400" src="https://3.bp.blogspot.com/-6nIbE31_nNE/Vxmq5H5-f_I/AAAAAAAAA6g/QkoSRuVFROcCFtu5ieU2mmDPImXNkXgYACKgB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-22%2B13.04.28.png" width="326" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Dockerホスト(Ubuntu 14.04.4 LTSです!)のユーザー名、ログインのためのRSA公開鍵、サブスクリプション、リソース、ロケーションを入力して「OK」<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-q-A3b8Aj8hg/Vxmq5Pl0W3I/AAAAAAAAA6Y/-4LNhfgM0r0IXYN116LHhm28t-KZs2qgQCKgB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-22%2B13.06.06.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="337" src="https://3.bp.blogspot.com/-q-A3b8Aj8hg/Vxmq5Pl0W3I/AAAAAAAAA6Y/-4LNhfgM0r0IXYN116LHhm28t-KZs2qgQCKgB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-22%2B13.06.06.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
オーケストレーションツールを「DC/OS(Mesos)」と「Swarm」から選んで「OK」<br />
※今回はSwarmを選択してみた<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-yW3-HsqtRGg/Vxmq5tdf4CI/AAAAAAAAA7I/PPXpVSEo_MInLExt0xFG2xMFigHs_C0zwCKgB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-22%2B13.06.32.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="337" src="https://1.bp.blogspot.com/-yW3-HsqtRGg/Vxmq5tdf4CI/AAAAAAAAA7I/PPXpVSEo_MInLExt0xFG2xMFigHs_C0zwCKgB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-22%2B13.06.32.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
ACSの設定です。<br />
エージェント数(コンテナホストのVM数ですね)、エージェントの仮想マシンのサイズ(デフォルトはStandard_D2)、マスターの数(冗長構成なら3以上)、DNSプレフィックスを入力して「OK」<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-7JKgRmZH3oc/Vxmq5tBK-hI/AAAAAAAAA7I/-KLC2_lUQKILLgYk24CdKJrplO87zQgMACKgB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-22%2B13.07.36.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="335" src="https://4.bp.blogspot.com/-7JKgRmZH3oc/Vxmq5tBK-hI/AAAAAAAAA7I/-KLC2_lUQKILLgYk24CdKJrplO87zQgMACKgB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-22%2B13.07.36.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
内容を確認して「OK」<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-feGyJ0u5c7M/Vxmq5s3N5HI/AAAAAAAAA7I/5f_H_hO9MC47G9oBFFheOpCbO4EvzdD-ACKgB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-22%2B13.08.15.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="255" src="https://1.bp.blogspot.com/-feGyJ0u5c7M/Vxmq5s3N5HI/AAAAAAAAA7I/5f_H_hO9MC47G9oBFFheOpCbO4EvzdD-ACKgB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-22%2B13.08.15.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
料金などの注意事項を読んでから「Create」でACS構築開始<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-LVZtf5_Qpos/Vxmq6OOuDFI/AAAAAAAAA7I/tFIcDWjADvMwEu0A9T0I3iXpu6gksG17ACKgB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-22%2B13.08.31.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="255" src="https://4.bp.blogspot.com/-LVZtf5_Qpos/Vxmq6OOuDFI/AAAAAAAAA7I/tFIcDWjADvMwEu0A9T0I3iXpu6gksG17ACKgB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-22%2B13.08.31.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
とにかく待つ<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-ymnfRTlGSPE/Vxmq6ANmBjI/AAAAAAAAA7I/y9Hg5Rr96cEr5mRdWp3KRatd74Fa-zhFgCKgB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-22%2B13.09.04.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="400" src="https://4.bp.blogspot.com/-ymnfRTlGSPE/Vxmq6ANmBjI/AAAAAAAAA7I/y9Hg5Rr96cEr5mRdWp3KRatd74Fa-zhFgCKgB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-22%2B13.09.04.png" width="308" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
できあがる<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-BmHYss0bsrw/Vxmq6Ri_RII/AAAAAAAAA7I/ngqPC_fz3WcXZKB1YiROiBwkNCiipQVTACKgB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-22%2B13.20.45.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="188" src="https://1.bp.blogspot.com/-BmHYss0bsrw/Vxmq6Ri_RII/AAAAAAAAA7I/ngqPC_fz3WcXZKB1YiROiBwkNCiipQVTACKgB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-22%2B13.20.45.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
「Resource Groups」からリソースを選び、デプロイ履歴を確認。<br />
「Outputs」の中に、MASTERFQDN、SSHMASTER0(ssh接続時のコマンド)、AGENTFQDN(実際のWebアプリのURI)があるので確認。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-ToLF4egmhhk/Vxmq65JDiLI/AAAAAAAAA7I/m1xoE2Mnx0kztMiH5uSSY4Vn-0LVMtN4gCKgB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-22%2B13.26.00.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="360" src="https://4.bp.blogspot.com/-ToLF4egmhhk/Vxmq65JDiLI/AAAAAAAAA7I/m1xoE2Mnx0kztMiH5uSSY4Vn-0LVMtN4gCKgB/s640/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-22%2B13.26.00.png" width="640" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
SSHでつないで、dockerコマンドでプロセスを見る。<br />
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, 'Trebuchet MS', sans-serif; font-size: 11px;">
<div class="p1">
<span class="s1">$ ssh xxx@xxxmgmt.japaneast.cloudapp.azure.com -A -p 2200</span></div>
<div class="p1">
<span class="s1">Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 3.19.0-58-generic x86_64)</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> * Documentation: https://help.ubuntu.com/</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> System information as of Fri Apr 22 04:20:31 UTC 2016</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> System load: 0.43 Processes: 138</span></div>
<div class="p1">
<span class="s1"> Usage of /: 5.7% of 28.80GB Users logged in: 0</span></div>
<div class="p1">
<span class="s1"> Memory usage: 3% IP address for eth0: 172.16.0.5</span></div>
<div class="p1">
<span class="s1"> Swap usage: 0% IP address for docker0: 172.17.0.1</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> Graph this data and manage this system at:</span></div>
<div class="p1">
<span class="s1"> https://landscape.canonical.com/</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> Get cloud support with Ubuntu Advantage Cloud Guest:</span></div>
<div class="p1">
<span class="s1"> http://www.ubuntu.com/business/services/cloud</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<br />
<span class="s1"></span></div>
<div class="p1">
<span class="s1">$ docker ps</span></div>
<div class="p1">
<span class="s1">CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES</span></div>
<div class="p1">
<span class="s1">0d9a7203292a yeasy/simple-web "/bin/sh -c 'python i" 26 seconds ago Up 24 seconds 0.0.0.0:32771->80/tcp xxx_web_1</span></div>
<div class="p1">
<span class="s1">822c18291112 swarm:1.1.0 "/swarm manage --repl" 11 minutes ago Up 9 minutes 0.0.0.0:2375->2375/tcp containers_swarm_1</span></div>
<div class="p1">
<span class="s1">618799d9ffee progrium/consul "/bin/start -server -" 11 minutes ago Up 9 minutes 0.0.0.0:8300-8302->8300-8302/tcp, 0.0.0.0:8400->8400/tcp, 53/tcp, 53/udp, 0.0.0.0:8500->8500/tcp, 0.0.0.0:8301-8302->8301-8302/udp containers_consul_1</span></div>
</div>
<div>
<br /></div>
<br />
以下の内容でdocker-compose.ymlを作成。<br />
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, 'Trebuchet MS', sans-serif; font-size: 11px;">
<div class="p1">
<span class="s1">$ vi docker-compose.yml </span></div>
<div class="p1">
<span class="s1">web:</span></div>
<div class="p1">
<span class="s1"> image: "yeasy/simple-web"</span></div>
<div class="p1">
<span class="s1"> ports:</span></div>
<div class="p1">
<span class="s1"> - "80"</span></div>
<div class="p1">
<span class="s1"> restart: "always"</span></div>
</div>
<div>
<br /></div>
docker-composeコマンドでデプロイ。そしてスケール。<br />
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, 'Trebuchet MS', sans-serif; font-size: 11px;">
<div class="p1">
<span class="s1">$ docker-compose up -d</span></div>
<div class="p1">
<span class="s1">xxx_web_1 is up-to-date</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">$ docker-compose scale web=5</span></div>
<div class="p1">
<span class="s1">Creating and starting 2 ... done</span></div>
<div class="p1">
<span class="s1">Creating and starting 3 ... done</span></div>
<div class="p1">
<span class="s1">Creating and starting 4 ... done</span></div>
<div class="p1">
<span class="s1">Creating and starting 5 ... done</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">$ docker ps</span></div>
<div class="p1">
<span class="s1">CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES</span></div>
<div class="p1">
<span class="s1">3e30842b5e74 yeasy/simple-web "/bin/sh -c 'python i" 6 seconds ago Up 3 seconds 0.0.0.0:32774->80/tcp xxx_web_5</span></div>
<div class="p1">
<span class="s1">96776a5764b5 yeasy/simple-web "/bin/sh -c 'python i" 6 seconds ago Up 3 seconds 0.0.0.0:32773->80/tcp xxx_web_4</span></div>
<div class="p1">
<span class="s1">f858be340919 yeasy/simple-web "/bin/sh -c 'python i" 6 seconds ago Up 3 seconds 0.0.0.0:32775->80/tcp xxx_web_2</span></div>
<div class="p1">
<span class="s1">57943899efc4 yeasy/simple-web "/bin/sh -c 'python i" 6 seconds ago Up 4 seconds 0.0.0.0:32772->80/tcp xxx_web_3</span></div>
<div class="p1">
<span class="s1">0d9a7203292a yeasy/simple-web "/bin/sh -c 'python i" 51 seconds ago Up 49 seconds 0.0.0.0:32771->80/tcp xxx_web_1</span></div>
<div class="p1">
<span class="s1">822c18291112 swarm:1.1.0 "/swarm manage --repl" 11 minutes ago Up 9 minutes 0.0.0.0:2375->2375/tcp containers_swarm_1</span></div>
<div class="p1">
<span class="s1">618799d9ffee progrium/consul "/bin/start -server -" 11 minutes ago Up 9 minutes 0.0.0.0:8300-8302->8300-8302/tcp, 0.0.0.0:8400->8400/tcp, 53/tcp, 53/udp, 0.0.0.0:8500->8500/tcp, 0.0.0.0:8301-8302->8301-8302/udp containers_consul_1</span></div>
</div>
<div>
<br /></div>
<strike>気になる点は、仮想マシンのスケールセットのCapacityに変更がない(でも問題なくdockerでスケールできてる)ことでしょうか?</strike><br />
仮想マシンもスケールしてました。<br />
<br />
これで気楽に(お金は気にしてねw)DockerでDevOpsに入門してねー。<br />
<br />
追記:Webアプリに繋がらんのでちょっと調べてみなければ...<br />
<br />
<br />Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0tag:blogger.com,1999:blog-7965762741197379921.post-65936746368920684452016-04-15T18:35:00.001+09:002016-04-15T18:35:12.152+09:00【Microsoft Azure】Azure Container Service の agent の数を増やしたい前回の<a href="http://it-next.blogspot.jp/2016/04/microsoft-azureazure-container-service.html" target="_blank">投稿</a>で設定したDockerコンテナですが、そのままではひとつ難点があります。<br />
スケールする場合のエージェントの数が増やせないのです。<br />
<br />
仮想マシンのスケールセット(以下VMSS)を利用しているので、本来であればポータルから変更したいところですが、今はまだできません。<br />
VMSSについてはこちら。<br />
<a href="https://azure.microsoft.com/ja-jp/documentation/articles/virtual-machine-scale-sets-windows-create/">https://azure.microsoft.com/ja-jp/documentation/articles/virtual-machine-scale-sets-windows-create/</a><br />
<br />
見てる限りでは、VMSSのcapacityを変更できれば、Docker側から設定した数を上限にスケールできそうです。<br />
今回はこれを変更するために、Azure Resource Explorer を使います。<br />
<a href="https://resources.azure.com/">https://resources.azure.com/</a><br />
<br />
まずAzure Resource Explorerに、ポータルにログインしているブラウザでアクセスします。<br />
このときに、右上の「Read/Write」をクリックして読み書き可能にする必要があります。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-Gy2m9_Vkwzo/VxCyqMOLXrI/AAAAAAAAA5c/BjmvWiKmAbYXAtjkXHvBUWz9XW7ntiXWwCLcB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-15%2B18.20.37.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="136" src="https://1.bp.blogspot.com/-Gy2m9_Vkwzo/VxCyqMOLXrI/AAAAAAAAA5c/BjmvWiKmAbYXAtjkXHvBUWz9XW7ntiXWwCLcB/s640/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-15%2B18.20.37.png" width="640" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
次は、左ペインのメニューを、<br />
subscription→ACSのサブスクリプション→resourceGroups→ACSのリソース→Microsoft.Compute→virtualMachineScaleSets→該当するScaleSet<br />
の順に選択します。<br />
<br />
ScaleSetのリソースは、こんな感じで表示されます。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-9SXBHgL4NOw/VxC0TOKw6iI/AAAAAAAAA5w/TxY5SBL8z3AA0wUKlMdnGwWcvtYOc18AQCLcB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-15%2B18.27.02.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="300" src="https://4.bp.blogspot.com/-9SXBHgL4NOw/VxC0TOKw6iI/AAAAAAAAA5w/TxY5SBL8z3AA0wUKlMdnGwWcvtYOc18AQCLcB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-15%2B18.27.02.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
「EDIT」をクリックして、「sku」の中の「capacity」を1から3に変更します。<br />
変更したら「PUT」を押します。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-5VHFJksn4lA/VxC0TEuBo-I/AAAAAAAAA5s/u0TXnmqYZfM1GtquG95lbVcvA7SAFur5wCKgB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-15%2B18.27.14.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="313" src="https://1.bp.blogspot.com/-5VHFJksn4lA/VxC0TEuBo-I/AAAAAAAAA5s/u0TXnmqYZfM1GtquG95lbVcvA7SAFur5wCKgB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-15%2B18.27.14.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
capacityが3に変更されました。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-3_lay5TxAcs/VxC0TpKMwXI/AAAAAAAAA58/nEzjZy3D-LMKUS8X_OTjoUJqmF96XRI2wCKgB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-15%2B18.27.29.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="326" src="https://4.bp.blogspot.com/-3_lay5TxAcs/VxC0TpKMwXI/AAAAAAAAA58/nEzjZy3D-LMKUS8X_OTjoUJqmF96XRI2wCKgB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-15%2B18.27.29.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
ポータルで見てみましょう。<br />
「仮想マシンのスケールセット」を探してみましょう。<br />
こんな風に3に変わっていると思います。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-w2Eaqu-u9Xk/VxCyLEr-kGI/AAAAAAAAA5k/cUtBFbU-BlQZx8W-XwryUu5EliB6OLz9gCKgB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-15%2B18.19.09.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="201" src="https://3.bp.blogspot.com/-w2Eaqu-u9Xk/VxCyLEr-kGI/AAAAAAAAA5k/cUtBFbU-BlQZx8W-XwryUu5EliB6OLz9gCKgB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-15%2B18.19.09.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
容量(capacity)が3になったので、docker-compose でスケールしてみましょう。<br />
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, 'Trebuchet MS', sans-serif; font-size: 11px;">
<span class="s1">azureuser@xxx:~$</span> docker-compose scale web=3</div>
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, 'Trebuchet MS', sans-serif; font-size: 11px;">
Creating and starting 2 ... done</div>
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, 'Trebuchet MS', sans-serif; font-size: 11px;">
Creating and starting 3 ... done</div>
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, 'Trebuchet MS', sans-serif; font-size: 11px;">
azureuser@xxx:~$ docker ps</div>
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, 'Trebuchet MS', sans-serif; font-size: 11px;">
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES</div>
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, 'Trebuchet MS', sans-serif; font-size: 11px;">
242e38975a34 yeasy/simple-web "/bin/sh -c 'python i" 5 seconds ago Up 4 seconds 0.0.0.0:32770->80/tcp azureuser_web_3</div>
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, 'Trebuchet MS', sans-serif; font-size: 11px;">
e27e1035774c yeasy/simple-web "/bin/sh -c 'python i" 5 seconds ago Up 4 seconds 0.0.0.0:32769->80/tcp azureuser_web_2</div>
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, 'Trebuchet MS', sans-serif; font-size: 11px;">
ae8a0ea43b50 yeasy/simple-web "/bin/sh -c 'python i" 45 minutes ago Up 45 minutes 0.0.0.0:32768->80/tcp azureuser_web_1</div>
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, 'Trebuchet MS', sans-serif; font-size: 11px;">
5a161555c072 swarm:1.1.0 "/swarm manage --repl" About an hour ago Up About an hour 0.0.0.0:2375->2375/tcp containers_swarm_1</div>
<div class="p2" style="background-color: black; color: #00f900; font-family: Helvetica, Arial, Verdana, 'Trebuchet MS', sans-serif; font-size: 11px;">
058236a13875 progrium/consul "/bin/start -server -" About an hour ago Up About an hour 0.0.0.0:8300-8302->8300-8302/tcp, 0.0.0.0:8400->8400/tcp, 53/tcp, 53/udp, 0.0.0.0:8500->8500/tcp, 0.0.0.0:8301-8302->8301-8302/udp containers_consul_1</div>
<div>
<br /></div>
<div>
前回の記事が1だったので、無事スケールできています。</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<span style="color: #00f900; font-size: 11px;"><br /></span></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0tag:blogger.com,1999:blog-7965762741197379921.post-87924116503210199132016-04-15T17:57:00.001+09:002016-04-15T18:05:36.052+09:00【Microsoft Azure】Azure Container Service で Docker と向き合ういろいろあってDockerと向き合うことになったので、Azure でやるなら Azure Container Service(以下ACS) を使ってみようと。<br />
<a href="https://azure.microsoft.com/ja-jp/services/container-service/">https://azure.microsoft.com/ja-jp/services/container-service/</a><br />
<br />
Apache Mesos または Docker Swarm のどちらかのオーケストレーションツールを使ってDockerコンテナを管理するっていうので、今回はDockerSwarmを選択。<br />
<br />
構成などについては、こちらのドキュメントをまずは読んでください。<br />
<a href="https://github.com/Azure/azure-quickstart-templates/blob/master/101-acs-swarm/docs/SwarmWalkthrough.md">https://github.com/Azure/azure-quickstart-templates/blob/master/101-acs-swarm/docs/SwarmWalkthrough.md</a><br />
<br />
ACSは、ポータルの「テンプレートからデプロイ」でARMテンプレートを使ってデプロイします。<br />
<a href="https://1.bp.blogspot.com/-ZmsZ_OtiOM8/VxCkBzKakeI/AAAAAAAAA4M/nB8eJ_DY-B0tGJNmoUnXnihGVyPFd0woQCLcB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-15%2B17.13.34.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="226" src="https://1.bp.blogspot.com/-ZmsZ_OtiOM8/VxCkBzKakeI/AAAAAAAAA4M/nB8eJ_DY-B0tGJNmoUnXnihGVyPFd0woQCLcB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-15%2B17.13.34.png" width="400" /></a><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
こちらから「テンプレートのデプロイ」を選択します。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-1NZaWt6Jgqk/VxCkB70ullI/AAAAAAAAA40/YNfLqUMlelY_O-ImDXHa4OChiZujuOHvgCKgB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-15%2B17.13.58.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="400" src="https://3.bp.blogspot.com/-1NZaWt6Jgqk/VxCkB70ullI/AAAAAAAAA40/YNfLqUMlelY_O-ImDXHa4OChiZujuOHvgCKgB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-15%2B17.13.58.png" width="285" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
ACSのテンプレートはgithubで公開されています。<br />
<a href="https://github.com/Azure/azure-quickstart-templates/tree/master/101-acs-swarm">https://github.com/Azure/azure-quickstart-templates/tree/master/101-acs-swarm</a> (これはDockerSwarmのもの)<br />
<br />
実際に使うARMテンプレートはこちら。これを<br />
<a href="https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-acs-swarm/azuredeploy.json">https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-acs-swarm/azuredeploy.json</a><br />
<br />
「テンプレートの編集」を選んで<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-IOLXkmZXFMU/VxCkCW_v54I/AAAAAAAAA40/jLJwkAn1nrYopwACTXE-eD8bG4OBjApcQCKgB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-15%2B17.14.28.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="320" src="https://1.bp.blogspot.com/-IOLXkmZXFMU/VxCkCW_v54I/AAAAAAAAA40/jLJwkAn1nrYopwACTXE-eD8bG4OBjApcQCKgB/s320/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-15%2B17.14.28.png" width="299" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
ACSのARMテンプレートを貼り付けて保存します。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-xqn2lQJbbP8/VxCkCSFeLXI/AAAAAAAAA40/e1Nf4_1G2HsJTzgkoMt2OOuqRCW_ZN5IwCKgB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-15%2B17.15.19.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="272" src="https://4.bp.blogspot.com/-xqn2lQJbbP8/VxCkCSFeLXI/AAAAAAAAA40/e1Nf4_1G2HsJTzgkoMt2OOuqRCW_ZN5IwCKgB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-15%2B17.15.19.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
次に、パラメーターをセットします。<br />
とりあえず、DNSNAMEPREFIX(FQDNにつける識別用プレフィックス)とSSHRSAPUBLICKEY(SSHでアクセスする際のRSA公開鍵)を入力して「OK」を押します。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-IJd4spEFDF4/VxCkCoJeO5I/AAAAAAAAA40/Ol6COxPOssU3aTCQnMdFUTSwyOzlvREfwCKgB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-15%2B17.15.36.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="383" src="https://3.bp.blogspot.com/-IJd4spEFDF4/VxCkCoJeO5I/AAAAAAAAA40/Ol6COxPOssU3aTCQnMdFUTSwyOzlvREfwCKgB/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-15%2B17.15.36.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
リソースグループを選ぶなり作成するなりして、リージョンを決めます。<br />
最後に、法律条項を確認して作成します。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-FSV2qZzS7pE/VxCkC9N81hI/AAAAAAAAA40/0k9azyiuXW0KCm4vq5ho9MPVn08WSbntgCKgB/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-15%2B17.17.00.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="320" src="https://1.bp.blogspot.com/-FSV2qZzS7pE/VxCkC9N81hI/AAAAAAAAA40/0k9azyiuXW0KCm4vq5ho9MPVn08WSbntgCKgB/s320/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-15%2B17.17.00.png" width="238" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
デプロイが終わると、以下の2つのFQDNが決定します。<br />
<br />
masterFQDN:{DNSNAMEPREFIX}mgmt.japaneast.cloudapp.azure.com<br />
agentFQDN: {DNSNAMEPREFIX}agents.japaneast.cloudapp.azure.com<br />
<br />
masterへのssh接続は、以下のようにします。公開鍵が登録されているので、秘密鍵のパスフレーズでログイン出来ます。<br />
<br />
<div class="p1" style="color: #00f900; font-family: Helvetica, Arial, Verdana, 'Trebuchet MS', sans-serif; font-size: 11px;">
<div style="background-color: black; color: #632035; font-size: 13px;">
<div style="color: #00f900; font-family: 'Hiragino Kaku Gothic ProN'; font-size: 11px;">
<div class="p1">
<span class="s1">$ ssh azureuser@{DNSNAMEPREFIX}mgmt.japaneast.cloudapp.azure.com -A -p 2200</span></div>
<div class="p1">
<br /></div>
<div class="p1">
Are you sure you want to continue connecting (yes/no)? yes</div>
<div class="p1">
<span class="s1">Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 3.19.0-58-generic x86_64)</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> * Documentation: https://help.ubuntu.com/</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> System information as of Fri Apr 15 08:28:32 UTC 2016</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> System load: 0.15 Memory usage: 1% Processes: 98</span></div>
<div class="p1">
<span class="s1"> Usage of /: 5.7% of 28.80GB Swap usage: 0% Users logged in: 0</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> Graph this data and manage this system at:</span></div>
<div class="p1">
<span class="s1"> https://landscape.canonical.com/</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1"> Get cloud support with Ubuntu Advantage Cloud Guest:</span></div>
<div class="p1">
<span class="s1"> http://www.ubuntu.com/business/services/cloud</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1">The programs included with the Ubuntu system are free software;</span></div>
<div class="p1">
<span class="s1">the exact distribution terms for each program are described in the</span></div>
<div class="p1">
<span class="s1">individual files in /usr/share/doc/*/copyright.</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1">Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by</span></div>
<div class="p1">
<span class="s1">applicable law.</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
</div>
<div class="p1">
<span class="s1">azureuser@xxx:~$</span> docker ps</div>
<div class="p1">
<span class="s1">CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES</span></div>
<div class="p1">
<span class="s1">5a161555c072 swarm:1.1.0 "/swarm manage --repl" 10 minutes ago Up 8 minutes 0.0.0.0:2375->2375/tcp containers_swarm_1</span></div>
<div class="p1">
<span class="s1">058236a13875 progrium/consul "/bin/start -server -" 10 minutes ago Up 8 minutes 0.0.0.0:8300-8302->8300-8302/tcp, 0.0.0.0:8400->8400/tcp, 53/tcp, 53/udp, 0.0.0.0:8500->8500/tcp, 0.0.0.0:8301-8302->8301-8302/udp containers_consul_1</span></div>
</div>
</div>
</div>
<br />
とりあえず動いています。<br />
ここで簡単なWebアプリコンテナを動かしてみます。<br />
以下の内容で、docker-compose.ymlというファイルを作成します。<br />
<div class="p1" style="background-color: black; color: #00f900; font-size: 11px;">
web:</div>
<div class="p1" style="background-color: black; color: #00f900; font-size: 11px;">
image: "yeasy/simple-web"</div>
<div class="p1" style="background-color: black; color: #00f900; font-size: 11px;">
ports:</div>
<div class="p1" style="background-color: black; color: #00f900; font-size: 11px;">
- "80"</div>
<div class="p1" style="background-color: black; color: #00f900; font-size: 11px;">
restart: "always"</div>
<br />
それから、docker-composeコマンドでコンテナをUPします。<br />
docker ps コマンドで確認できます。<br />
<div class="p1" style="background-color: black; color: #00f900; font-size: 11px;">
<span class="s1">azureuser@xxx:~$</span> docker-compose up -d</div>
<div class="p1" style="background-color: black;">
<span style="color: #00f900;"><span style="font-size: 11px;">Pulling web (yeasy/simple-web:latest)...</span></span></div>
<div class="p1" style="background-color: black;">
<span style="color: #00f900;"><span style="font-size: 11px;">latest: Pulling from yeasy/simple-web</span></span></div>
<div class="p1" style="background-color: black;">
<span style="color: #00f900;"><span style="font-size: 11px;">efd26ecc9548: Pull complete</span></span></div>
<div class="p1" style="background-color: black;">
<span style="color: #00f900;"><span style="font-size: 11px;">a3ed95caeb02: Pull complete</span></span></div>
<div class="p1" style="background-color: black;">
<span style="color: #00f900;"><span style="font-size: 11px;">d1784d73276e: Pull complete</span></span></div>
<div class="p1" style="background-color: black;">
<span style="color: #00f900;"><span style="font-size: 11px;">72e581645fc3: Pull complete</span></span></div>
<div class="p1" style="background-color: black;">
<span style="color: #00f900;"><span style="font-size: 11px;">9709ddcc4d24: Pull complete</span></span></div>
<div class="p1" style="background-color: black;">
<span style="color: #00f900;"><span style="font-size: 11px;">2d600f0ec235: Pull complete</span></span></div>
<div class="p1" style="background-color: black;">
<span style="color: #00f900;"><span style="font-size: 11px;">de1491f1bbd4: Pull complete</span></span></div>
<div class="p1" style="background-color: black;">
<span style="color: #00f900;"><span style="font-size: 11px;">4becc568d2ff: Pull complete</span></span></div>
<div class="p1" style="background-color: black;">
<span style="color: #00f900;"><span style="font-size: 11px;">6aeb62f4b3fa: Pull complete</span></span></div>
<div class="p1" style="background-color: black;">
<span style="color: #00f900;"><span style="font-size: 11px;">77144c15ca8f: Pull complete</span></span></div>
<div class="p1" style="background-color: black;">
<span style="color: #00f900;"><span style="font-size: 11px;">811db2e8b100: Pull complete</span></span></div>
<div class="p1" style="background-color: black;">
<span style="color: #00f900;"><span style="font-size: 11px;">Digest: sha256:35e52520b8f98a092af6ce10c9fdd3ca6ca77f0b79f9d652c29bdd5d17c1c7aa</span></span></div>
<div class="p1" style="background-color: black;">
<span style="color: #00f900;"><span style="font-size: 11px;">Status: Downloaded newer image for yeasy/simple-web:latest</span></span></div>
<div class="p1" style="background-color: black;">
<span style="color: #00f900;"><span style="font-size: 11px;">Creating azureuser_web_1</span></span></div>
<div class="p2" style="background-color: black; color: #00f900; font-size: 11px;">
<span class="s1">azureuser@xxx:~$</span> docker ps<span class="s1"></span></div>
<div class="p2" style="background-color: black; color: #00f900; font-size: 11px;">
<span class="s1"></span></div>
<div class="p1" style="background-color: black;">
<span style="color: #00f900;"><span style="font-size: 11px;">CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES</span></span></div>
<div class="p1" style="background-color: black;">
<span style="color: #00f900;"><span style="font-size: 11px;">ae8a0ea43b50 yeasy/simple-web "/bin/sh -c 'python i" 23 seconds ago Up 22 seconds 0.0.0.0:32768->80/tcp azureuser_web_1</span></span></div>
<div class="p1" style="background-color: black;">
<span style="color: #00f900;"><span style="font-size: 11px;">5a161555c072 swarm:1.1.0 "/swarm manage --repl" 20 minutes ago Up 19 minutes 0.0.0.0:2375->2375/tcp containers_swarm_1</span></span></div>
<div class="p1" style="background-color: black;">
<span style="color: #00f900;"><span style="font-size: 11px;">058236a13875 progrium/consul "/bin/start -server -" 20 minutes ago Up 19 minutes 0.0.0.0:8300-8302->8300-8302/tcp, 0.0.0.0:8400->8400/tcp, 53/tcp, 53/udp, 0.0.0.0:8500->8500/tcp, 0.0.0.0:8301-8302->8301-8302/udp containers_consul_1</span></span><span style="color: #00f900; font-size: 11px;"> containers_swarm_1</span></div>
<br />
ブラウザから「{DNSNAMEPREFIX}agents.japaneast.cloudapp.azure.com」へアクセスするとWebアプリの画面が見えます。<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0tag:blogger.com,1999:blog-7965762741197379921.post-40429154476541217172016-04-08T23:43:00.003+09:002016-04-08T23:43:51.977+09:00Microsoft Azure Web Apps で LINE BOT を動かせLINE BOT API のトライアル、みんな申し込んでますよね?<br />
<a href="https://business.line.me/ja/products/4/introduction">https://business.line.me/ja/products/4/introduction</a><br />
<br />
もちろん、Azure Web Apps と PHP でやりますよ。<br />
と思いましたが、みんなブログ書いてるので、WebApps固有のハマったポイントを。<br />
<br />
プログラムを書くために参考にしたのは、このブログ。助かります。<br />
<a href="http://qiita.com/srea/items/58ba0f7d870a6ee3da2a">http://qiita.com/srea/items/58ba0f7d870a6ee3da2a</a><br />
<br />
で、まずは Server IP Whitelist に追加するIPアドレス。<br />
<div class="separator" style="clear: both; text-align: left;">
Settings -> Properties の「OUTBOUND IP ADDRESSES」にあるIPアドレスを全部登録します。</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-aquZC9e1qtU/VwfBwkioCSI/AAAAAAAAA3w/Zha2T4vCfu8ANbtLhfEw6bzpG--fwd0Yw/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-08%2B23.35.09.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="211" src="https://2.bp.blogspot.com/-aquZC9e1qtU/VwfBwkioCSI/AAAAAAAAA3w/Zha2T4vCfu8ANbtLhfEw6bzpG--fwd0Yw/s400/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-08%2B23.35.09.png" width="400" /></a><a href="https://2.bp.blogspot.com/-aquZC9e1qtU/VwfBwkioCSI/AAAAAAAAA3w/Zha2T4vCfu8ANbtLhfEw6bzpG--fwd0Yw/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-08%2B23.35.09.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><br /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
もう一つは、リクエストに使うcurlの証明書エラー。こんな感じ。<br />
<br />
<span style="background-color: white; color: #6a6a6a; font-family: arial, sans-serif; font-size: x-small; font-weight: bold; line-height: 18.2px;">SSL certificate problem</span><span style="background-color: white; color: #545454; font-family: arial, sans-serif; font-size: x-small; line-height: 18.2px;">: unable to get local issuer certificate</span><br />
<div>
<br /></div>
<div>
こいつは、以下のように今回は証明書の検証をしないようにします。</div>
<div>
<br /></div>
<div>
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false);</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-aquZC9e1qtU/VwfBwkioCSI/AAAAAAAAA3w/Zha2T4vCfu8ANbtLhfEw6bzpG--fwd0Yw/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-08%2B23.35.09.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"></a><a href="https://2.bp.blogspot.com/-aquZC9e1qtU/VwfBwkioCSI/AAAAAAAAA3w/Zha2T4vCfu8ANbtLhfEw6bzpG--fwd0Yw/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-08%2B23.35.09.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><br /></a><a href="https://2.bp.blogspot.com/-aquZC9e1qtU/VwfBwkioCSI/AAAAAAAAA3w/Zha2T4vCfu8ANbtLhfEw6bzpG--fwd0Yw/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-08%2B23.35.09.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><br /></a><a href="https://2.bp.blogspot.com/-aquZC9e1qtU/VwfBwkioCSI/AAAAAAAAA3w/Zha2T4vCfu8ANbtLhfEw6bzpG--fwd0Yw/s1600/%25E3%2582%25B9%25E3%2582%25AF%25E3%2583%25AA%25E3%2583%25BC%25E3%2583%25B3%25E3%2582%25B7%25E3%2583%25A7%25E3%2583%2583%25E3%2583%2588%2B2016-04-08%2B23.35.09.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><br /></a></div>
Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0tag:blogger.com,1999:blog-7965762741197379921.post-41734138043203326002016-04-07T10:26:00.001+09:002016-04-07T10:26:50.159+09:00Ubuntu on Windows を試すInsider Preview 14316 で、Ubuntu on Windows が動きます。<br />
<br />
まずは、Windowsの機能で「Windows Subsystem for Linux (Beta)」を有効にします。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-PMXDAvRXwuA/VwW2VfD3NTI/AAAAAAAAA3U/odPz4LYyLmkMu-WBXWKsVNbOKhHNYT0bw/s1600/p1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="472" src="https://4.bp.blogspot.com/-PMXDAvRXwuA/VwW2VfD3NTI/AAAAAAAAA3U/odPz4LYyLmkMu-WBXWKsVNbOKhHNYT0bw/s640/p1.png" width="640" /></a></div>
<br />
一旦再起動します。<br />
<br />
次はPowerShellで、「bash」と入力してEnter。<br />
初回はストアから「Ubuntu on Windows」をダウンロードしてきます。<br />
ダウンロードするとbashが使えます。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-Sf665eRf2eU/VwW2VZ3ZG4I/AAAAAAAAA3Q/DMr1t6p9XhIEX8SzDLpmOkFn31l5wKPrQ/s1600/p3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="224" src="https://2.bp.blogspot.com/-Sf665eRf2eU/VwW2VZ3ZG4I/AAAAAAAAA3Q/DMr1t6p9XhIEX8SzDLpmOkFn31l5wKPrQ/s640/p3.png" width="640" /></a></div>
<br />
uname で見てみると、一応Linux 3.4.0 と表示されてます。<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-7TGSvCBt6iA/VwW2VfnoSwI/AAAAAAAAA3Y/aZPgK6Jqj9wl-p658bcslkRX3dmZOSpPw/s1600/p2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="336" src="https://2.bp.blogspot.com/-7TGSvCBt6iA/VwW2VfnoSwI/AAAAAAAAA3Y/aZPgK6Jqj9wl-p658bcslkRX3dmZOSpPw/s640/p2.png" width="640" /></a></div>
<br />
<br />
<br />Takeshi Sakuraihttp://www.blogger.com/profile/06672491882519406329noreply@blogger.com0