Creating Service Fabric using a secret pointer to a Certificate in Key Vault fails with "ERROR: list index out of range"
Describe the bug
When trying to create a Service Fabric Cluster using the Azure CLI the message "ERROR: list index out of range" is displayed and the create fails. It looks like the stack trace points to a python function called _get_vault_from_secret_identifier. See stack trace below:
list index out of range
Traceback (most recent call last):
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-jvxpk9ku\knack\knack\cli.py", line 197, in invoke
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-jvxpk9ku\azure-cli-core\azure\cli\core\commands\__init__.py", line 373, in execute
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-jvxpk9ku\six\six.py", line 693, in reraise
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-jvxpk9ku\azure-cli-core\azure\cli\core\commands\__init__.py", line 347, in execute
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-jvxpk9ku\azure-cli-core\azure\cli\core\commands\__init__.py", line 182, in __call__
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-jvxpk9ku\azure-cli-core\azure\cli\core\__init__.py", line 440, in default_command_handler
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-jvxpk9ku\azure-cli-servicefabric\azure\cli\command_modules\servicefabric\custom.py", line 204, in new_cluster
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-jvxpk9ku\azure-cli-servicefabric\azure\cli\command_modules\servicefabric\custom.py", line 1107, in _create_certificate
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-jvxpk9ku\azure-cli-servicefabric\azure\cli\command_modules\servicefabric\custom.py", line 1334, in _get_vault_from_secret_identifier
IndexError: list index out of range
To Reproduce
- Create a ResourceGroup called "TestSfCluster" and a Key Vault in that Cluster named "Test-SF-Keyvault".
- Enable the Key Vault for Deployments
az keyvault update --name 'Test-SF-Keyvault' --resource-group 'TestSfCluster' --enabled-for-deployment 'true'
- Create a Certificate in the keyvault with the name "TestSfCluster" with the subject set to "CN=TestSfCluster.southcentralus.cloudapp.azure.com"
- The following Powershell script can be used to reproduce the bug
# Variables
$ResourceGroupName="TestSfCluster"
$ClusterName= "$ResourceGroupName"
$Location="southcentralus"
$VaultName="Test-SF-Keyvault"
$VmPassword = "VmPassword"
$VmUserName = "VmUser"
$sid = az keyvault certificate show --name $ClusterName --vault-name $VaultName --query 'sid'
$sid = $sid.Trim('"')
Write-Output "SecretId: $sid"
Write-Output "[+] Creating Service Fabric Cluster $ClusterName in $ResourceGroupName"
az sf cluster create --resource-group $ResourceGroupName --location $Location `
--cluster-name $ClusterName --cluster-size 5 --os WindowsServer2016Datacenter --vault-name $VaultName `
--resource-group $ResourceGroupName `
--vm-password "$VmPassword" --vm-user-name $VmUserName --secret-identifier $sid --debug
Expected behavior The Service Fabric Cluster is created and the Certificate in the Key Vault referenced by the SecretId passed to the create command is used as the cluster certificate.
Environment summary Install Method (e.g. pip, interactive script, apt-get, Docker, MSI, edge build) MSI
CLI version (az --version)
PS C:\Repos\samples\ServiceFabricCreateAndDeploy-scripts> az --version
azure-cli (2.0.50)
acr (2.1.8)
acs (2.3.11)
advisor (2.0.0)
ams (0.3.0)
appservice (0.2.6)
backup (1.2.1)
batch (3.4.1)
batchai (0.4.4)
billing (0.2.0)
botservice (0.1.1)
cdn (0.2.0)
cloud (2.1.0)
cognitiveservices (0.2.3)
command-modules-nspkg (2.0.2)
configure (2.0.19)
consumption (0.4.0)
container (0.3.8)
core (2.0.50)
cosmosdb (0.2.3)
dla (0.2.3)
dls (0.1.4)
dms (0.1.1)
eventgrid (0.2.0)
eventhubs (0.3.1)
extension (0.2.3)
feedback (2.1.4)
find (0.2.12)
hdinsight (0.1.0)
interactive (0.4.0)
iot (0.3.4)
iotcentral (0.1.3)
keyvault (2.2.6)
lab (0.1.3)
maps (0.3.2)
monitor (0.2.6)
network (2.2.8)
nspkg (3.0.3)
policyinsights (0.1.0)
profile (2.1.2)
rdbms (0.3.4)
redis (0.3.2)
relay (0.1.2)
reservations (0.4.0)
resource (2.1.6)
role (2.1.9)
search (0.1.1)
servicebus (0.3.2)
servicefabric (0.1.7)
signalr (1.0.0)
sql (2.1.5)
storage (2.2.4)
telemetry (1.0.0)
vm (2.2.7)
Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\user\.azure\cliextensions'
Python (Windows) 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 02:47:15) [MSC v.1900 32 bit (Intel)]
OS version Windows 10 Pro 64-bit (10.0, Build 16299)
Shell Type (e.g. bash, cmd.exe, Bash on Windows)
Powershell
Additional context