これはなに?
Azure CLI (xplat-cli)でログイン後に何かすると、security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.と怒られる場合の対処方法。
メモレベルです。
環境
$ azure -v
0.9.18
## 2016/03/15時点の最新版
OSX EI Capitan
10.11.3
現象
Azure CLIでログイン後、なにか操作しようとすると掲題のエラーが出て何も出来ない。
$ azure login -u [メアド]
$ azure group list
info: Executing command group list
+ Listing resource groups
error: Command failed: /usr/bin/security find-generic-password -a _authority:https\://login.windows.net/common::_clientId:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx::expiresIn:3599::expiresOn:2016-03-15T07\:46\:41.218Z::familyName:xxxxxxxxx::givenName:xxxxxxxxx::isMRRT:true::isUserIdDisplayable:true::resource:https\://management.core.windows.net/::tenantId:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx::tokenType:Bearer::userId:xxxx@xxxxx.com -s https://management.core.windows.net/ -g
security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.
$
解決方法
1or2のどちらかで解決できるはず
1. Multi-Factor Authenticationが有効になっているケース
$ azure login -u [メアド]
ではなく
$ azure login
とすると
info: Executing command login
|info: To sign in, use a web browser to open the page https://aka.ms/devicelogin. Enter the code [コードコードコード] to authenticate.
となるのでブラウザでhttps://aka.ms/deviceloginを開いて認証すればOK
2. Azure CLIのversionが古く、Azure ADのアカウント情報にマルチバイトが含まれている場合
2-1. Keychainのazure access tokenをクリアする
Key chainを開き、右上の検索窓に"azure access token"と入力して検索、出てきたものを削除する
2-2. Azure CLIを新しいバージョンにアップデートする
きっちり確認していないけど2015年のどこかの時点のバージョンでは、ADのアカウント情報にマルチバイトのものが含まれていると挙動がおかしくなるバグが有ったみたい。