Azureの小ネタ (改)

~Azureネタを中心に、色々とその他の技術的なことなどを~

build 2015 Azure関連セッション一覧

build 2015 Azure関連 セッション一覧

build 2015 Azure関連セッションの一覧です。http://channel9.msdn.com/Events/Build/2015?sort=status&direction=asc#tab_sortBy_status から タイトルにAzureを含むものを適当に分類してあります。

General
IoT
Azure resource Manager
Next gen
Apps
Media service
Big data
Storage, SQL, NoSQL
Active directory
Visual Studio
Service Fabric
New portal
Others
P.S.
  • はてな記法で、自動タイトルにしておいたら、毎回 "Channel 9" とかタイトルに出てうざいとご指摘があったので、タイトル埋め込みました(curlでざざっと取得してタイトルをアドホックに加工)
  • 適当に分類しました。

既存の仮想マシンに対して、IPアドレスを固定化する

Azureには、固定的なIPアドレスを設定する、Reserved IP ってのがあります。ようはIPアドレスを予約して、仮想マシン作成時に付与するような使い方をすることで、IPアドレスを固定的に使えます。

ちなみに、以前は仮想マシン作成時にしかIPアドレスを固定化することができませんでしたが、build 2015 のアップデートにおいて起動中の仮想マシンに対しても割り当てることが可能になったため、試してみました。

IPアドレスの予約

まずは、IPアドレスを取得というか予約しておく必要があります。これは New-AzureReservedIP コマンドで行います。当たり前といえば、当たり前ですが、Locationを指定する必要があることに注意してください。

PS C:\> New-AzureReservedIP -ReservedIPName "testrip" -Location "japan west"
詳細: 16:25:20 - Begin Operation: New-AzureReservedIP
詳細: 16:25:53 - Completed Operation: New-AzureReservedIP

OperationDescription                                 OperationId                                          OperationStatus                                     
--------------------                                 -----------                                          ---------------                                     
New-AzureReservedIP                                  6363aa16-8f92-94b4-adcc-a214ac5c009d                 Succeeded                                           

コマンドが正常終了したら、Get-AzureReservedIP で確認してみます。以下のIPアドレスが予約されました。InUse が False になっていることから、まだ使用されていないことが分かります。

PS C:\> Get-AzureReservedIP -ReservedIPName "testrip"
詳細: 16:27:45 - Begin Operation: Get-AzureReservedIP
詳細: 16:27:49 - Completed Operation: Get-AzureReservedIP


ReservedIPName       : testrip
Address              : 104.214.136.75
Id                   : a02c020a-1f97-489d-a426-f390eb103f07
Label                : 
Location             : Japan West
State                : Created
InUse                : False
ServiceName          : 
DeploymentName       : 
VirtualIPName        : 
OperationDescription : Get-AzureReservedIP
OperationId          : c62b7e20-53f6-97da-ad97-f173471e2601
OperationStatus      : Succeeded

仮想マシン作成時での割当(従来からの方法)

従来は、仮想マシン作成タイミングで、New-AzureVM の ReservedIPName に引数として渡していました。

New-AzureVM -ServiceName "SomeService" -VMs $vmConfig -ReservedIPName $ReservedIPName 

既存の仮想マシンへの割当

現状では起動中のVMに対して予約することができます。とりあえずVMを1つ起動してみます。ちなみに仮想マシン停止中は割り当てを変更することはできません。

New-AzureQuickVM -Linux -ServiceName "testripsv" -Location "japan west" -LinuxUser "hogeuser" -Password "fugapassword" -ImageName "b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-14_10-amd64-server-20150509-en-us-30GB"

作成が完了したら、nslookup や ポータルからパブリック仮想 IP (VIP) アドレスを確認してみましょう。

IPアドレスを割り当てる

IPアドレスの割当には、 Set-AzureReservedIPAssociation コマンドを使います。

Set-AzureReservedIPAssociation -ServiceName testripsv -ReservedIPName testrip
詳細: 16:42:50 - Begin Operation: Set-AzureReservedIPAssociation
詳細: 16:44:25 - Completed Operation: Set-AzureReservedIPAssociation

OperationDescription                                 OperationId                                          OperationStatus                                     
--------------------                                 -----------                                          ---------------                                     
Set-AzureReservedIPAssociation                       46717ba2-44ee-9189-b893-e525c533be85                 Succeeded                                           

成功したら先ほどと同じく、Get-AzureReservedIP コマンドで確認してみます。 InUseやServiceName などに値が格納されているのが確認できます。

PS C:\> Get-AzureReservedIP -ReservedIPName "testrip"
詳細: 16:49:43 - Begin Operation: Get-AzureReservedIP
詳細: 16:49:46 - Completed Operation: Get-AzureReservedIP


ReservedIPName       : testrip
Address              : 104.214.136.75
Id                   : a02c020a-1f97-489d-a426-f390eb103f07
Label                : 
Location             : Japan West
State                : Created
InUse                : True
ServiceName          : testripsv
DeploymentName       : testripsv
VirtualIPName        : testripsvContractContract
OperationDescription : Get-AzureReservedIP
OperationId          : 456624c8-80be-924a-8921-2ab21bb2dff6
OperationStatus      : Succeeded

nslookupで確認すると予約したIPアドレスが割り当てられていることが確認できます。

名前:    testripsv.cloudapp.net
Address:  104.214.136.75

割当の解除

割当の解除も、Remove-AzureReservedIPAssociation コマンドで問題なくできます。

以上

Visual Studio Code を試す

Visual Studio の簡易エディタ的な、Visual Studio Codeが発表されたので触った感触など。Windowsはもちろん、Mac、Linuxで動作するという優れものです。

以下が本家のサイトです。ここから情報を取得できます。

https://code.visualstudio.com/

f:id:StateMachine:20150507165117p:plain

今回検証した環境は、Hyper-V配下のUbuntu Desktop 14.04 LTS です。ちなみに、 VS Codeは、64bit版のバイナリのみの配布のようですので、OSも64bitにしましょう。

ダウンロード&インストール

上記URLからダウンロードするとZIPファイルが取得できます。適当に任意のフォルダに展開してパスを設定します。

展開したフォルダは以下のような感じです。余談ですが、展開されたフォルダをたぐっていくとJavaScriptファイルが多数みてとれます。Visual Studio Online "Monaco"由来のようです。

$ unzip VSCode-linux-x64.zip -d VSCode 
$ cd VSCode
$ ls -al
total 109952
drwxrwxr-x 4 moris moris     4096 May  7 17:07 .
drwxr-xr-x 4 moris moris     4096 May  7 21:08 ..
-rwxrwxr-x 1 moris moris 11224136 Mar 29 13:50 Code
-rw-rw-rw- 1 moris moris   869779 Apr 28 14:37 Credits_41.0.2272.76.html
-rw-rw-rw- 1 moris moris   122259 Apr 28 14:37 ThirdPartyNotices.txt
-rw-rw-r-- 1 moris moris  8437142 Mar 29 13:17 content_shell.pak
-rw-rw-r-- 1 moris moris 10457856 Mar 29 13:17 icudtl.dat
-rw-rw-r-- 1 moris moris 76984472 Mar 29 13:50 libchromiumcontent.so
-rw-rw-r-- 1 moris moris  2496440 Mar 29 13:50 libffmpegsumo.so
-rw-rw-r-- 1 moris moris   520152 Mar 29 13:50 libgcrypt.so.11
-rw-rw-r-- 1 moris moris    31256 Mar 29 13:50 libnotify.so.4
-rw-rw-rw- 1 moris moris    10056 Apr 28 14:37 license.txt
drwxrwxr-x 2 moris moris     4096 May  7 15:08 locales
-rw-rw-r-- 1 moris moris   413533 Mar 29 13:17 natives_blob.bin
drwxrwxr-x 3 moris moris     4096 May  7 15:08 resources
-rw-rw-r-- 1 moris moris   985220 Mar 29 13:17 snapshot_blob.bin

起動

Code が実行ファイルです。fileするとバイナリってなってますん。

$ file Code
Code: ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=176e777a52b1683e73d2eb69527b98ddaebc5e6f, stripped

適当に実行してみるとVS Codeが起動します。

$ ./Code .

f:id:StateMachine:20150507211609p:plain

何か編集してみる

とりあえずNodeのなんかを編集してみたいとおもいます。node.js と npm はインストーしてください。

$ sudo npm install -g express
$ sudo npm install -g express-generator
$ express myapp
$ cd myapp
$ npm install
$ node ./bin/www

上記でExpressのアプリのひな形を作成し実行してみます。Expressが起動すればOKです。

f:id:StateMachine:20150507212616p:plain

myappフォルダをVS Codeで開いてみます。jsファイルがコードハイライトされて表示されているのが確認できました。

f:id:StateMachine:20150507212919p:plain

所々で補完も効きます。

f:id:StateMachine:20150508101504p:plain

デバッグ

デバッグには、launch.jsonファイルと、mono 3.10.0 以上が必要です。launch.jsonは、.settings配下に存在するので、F5を押せばデバッグ開始ですが、環境によっては以下のようにエラーがでるでしょう。

f:id:StateMachine:20150508110213p:plain

stackoverflowにも書かれていますが、

stackoverflow.com

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
sudo apt-get install mono-complete
mono --version

で、さくっと最新版(この時点で、4.0.1) が入ります。

ちなみに、.setting/launch.json は以下です。

{
        "version": "0.1.0",
        // List of configurations. Add new configurations or edit existing ones.
        // ONLY "node" and "mono" are supported, change "type" to switch.
        "configurations": [
                {
                        // Name of configuration; appears in the launch configuration drop down menu.
                        "name": "Launch app.js",
                        // Type of configuration. Possible values: "node", "mono".
                        "type": "node",
                        // Workspace relative or absolute path to the program.
                        "program": "app.js",
                        // Automatically stop program after launch.
                        "stopOnEntry": true,
                        // Command line arguments passed to the program.
                        "args": [],
                        // Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
                        "cwd": ".",
                        // Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
                        "runtimeExecutable": null,
                        // Environment variables passed to the program.
                        "env": { }
                },
                {
                        "name": "Attach",
                        "type": "node",
                        // TCP/IP address. Default is "localhost".
                        "address": "localhost",
                        // Port to attach to.
                        "port": 5858
                }
        ]
}

ふたたびデバッグを試してみると、以下のような感じでBreakpointを設定してデバッグできたりしました。

f:id:StateMachine:20150508110114p:plain

雑感

  • VSの利用領域が広がるのはいい感じですが、久しくLinux(Unix) のデスクトップを使っていないので、どうなんでしょう。Macな人にとってはWelcomeなんでしょうか。
  • Hyper-V配下で実行したんですが、エディタでマウスのスクロールボタンがうまく動きませんでした。他のアプリではキチント動作していたので、VS Code固有の問題でしょうか?
  • やっぱEmacsキーバインディングが欲しい。キーバインディング含む、設定情報はすべてJSONで定義されてるので、がんばってカスタマイズすれば対応できるかもしれませんが、編集はEmacs + OmniSharpでいいのではないかという気も。