Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Account Setup script fails in Cloud Shell #368

Open
etiennebr opened this issue Mar 1, 2020 · 7 comments
Open

Account Setup script fails in Cloud Shell #368

etiennebr opened this issue Mar 1, 2020 · 7 comments

Comments

@etiennebr
Copy link

I have an issue when setting up my account on Azure Cloud Shell using the instructions in the README. I have an Azure Batch Service account, I tried restarting the Cloud Shell, but I always get this error TypeError: signed_session() takes 1 positional argument but 2 were given.

wget -q https://raw.githubusercontent.com/Azure/doAzureParallel/master/account_setup.sh &&
chmod 755 account_setup.sh &&
/bin/bash account_setup.sh
# Installing dependencies...
# Finished installing dependencies.
# Getting account setup script...
# Finished getting account setup script.
# Running account setup script...
# 
# Getting credentials.
# Your credentials class does not support session injection. Performance will not be at the maximum.
# Traceback (most recent call last):
#   File "/home/etienne/.local/lib/python3.5/site-packages/msrest/pipeline/requests.py", line 65, in send
# self._creds.signed_session(session)
# File "/home/etienne/.local/lib/python3.5/site-packages/azure/common/credentials.py", line 78, in signed_session
# return credentials.signed_session(session)
# TypeError: signed_session() takes 1 positional argument but 2 were given
# 
# During handling of the above exception, another exception occurred:
#   
#   Traceback (most recent call last):
#   File "account_setup.py", line 445, in <module>
#   tenant_ids = [tenant.id for tenant in subscription_client.tenants.list()]
# File "account_setup.py", line 445, in <listcomp>
#   tenant_ids = [tenant.id for tenant in subscription_client.tenants.list()]
# File "/home/etienne/.local/lib/python3.5/site-packages/msrest/paging.py", line 143, in __next__
# self.advance_page()
# File "/home/etienne/.local/lib/python3.5/site-packages/msrest/paging.py", line 129, in advance_page
# self._response = self._get_next(self.next_link)
# File "/home/etienne/.local/lib/python3.5/site-packages/azure/mgmt/subscription/operations/tenants_operations.py", line 81, in internal_paging
# request, header_parameters, **operation_config)
# File "/home/etienne/.local/lib/python3.5/site-packages/msrest/service_client.py", line 336, in send
# pipeline_response = self.config.pipeline.run(request, **kwargs)
# File "/home/etienne/.local/lib/python3.5/site-packages/msrest/pipeline/__init__.py", line 197, in run
# return first_node.send(pipeline_request, **kwargs)  # type: ignore
# File "/home/etienne/.local/lib/python3.5/site-packages/msrest/pipeline/__init__.py", line 150, in send
# response = self.next.send(request, **kwargs)
# File "/home/etienne/.local/lib/python3.5/site-packages/msrest/pipeline/requests.py", line 68, in send
# request.context.session = session = self._creds.signed_session()
# File "/home/etienne/.local/lib/python3.5/site-packages/azure/common/credentials.py", line 78, in signed_session
# return credentials.signed_session(session)
# TypeError: signed_session() takes 1 positional argument but 2 were given
@etiennebr
Copy link
Author

I managed to go a little further by upgrading the dependencies, but it still seems like the azure-mgmt-storage would require a specific version because I get

[...]
Created Resource Group.
Traceback (most recent call last):
  File "account_setup.py", line 501, in <module>
    storage_account_id = create_storage_account(creds, subscription_id, **kwargs)
  File "account_setup.py", line 99, in create_storage_account
    sku=Sku(SkuName.standard_lrs),
TypeError: __init__() takes 1 positional argument but 2 were given

with: etiennebr#1

@YannickAlthans
Copy link

I am having the same issue, have you found a solution yet?

@etiennebr
Copy link
Author

I haven't found a solution, so I created my credentials.json manually, this is what it looks like:

{
    "batchAccount": {
        "key": "6GZRr5UKmYdjdLKcju... long key",
        "url": "https://my_account.my_location.batch.azure.com",
        "name": "batch_account_name"
    },
    "storageAccount": {
        "key": "u/K2LPaiZxnX7SAGJCfq8... long key",
        "endpointSuffix": "core.windows.net",
        "name": "my_storage_name"
    }
}

@YannickAlthans
Copy link

Thank you for the response, I guess I will try doing the same.

@jdthorpe
Copy link

jdthorpe commented Jul 2, 2020

If you don't mind having the same string for the resource group, batch account and storage account, here's a little script you can copy the Azure Cloud Shell. Note that the $name parameter must be 7-22 characters containing just numbers and letters, start with a letter and be unique across all of azure.

# parameters
$name = "<<replace with valid name>>"  # name of the resource group, storage account, and batch account
$location = "westus2"

# create the resources
az group create -l $location -n $name
az storage account create -n $name -l $location -g $name
az batch account create -n $name -l $location -g $name --storage-account $name

# query the keys
$ACCOUNT_ENV_NAME = (az account show --query environmentName) -replace '"',''
$STORAGE_SUFFIX = Get-AzEnvironment | ?{$_.name -eq $ACCOUNT_ENV_NAME} | Select -ExpandProperty "StorageEndpointSuffix"
$BATCH_ACCOUNT_KEY =  (az batch account keys list -n $name -g $name --query primary) -replace '"',''
$BATCH_ACCOUNT_ENDPOINT =  (az batch account show -n $name -g $name --query accountEndpoint) -replace '"',''
$STORAGE_ACCOUNT_KEY = (az storage account keys list -n $name --query [0].value) -replace '"',''

# generate the output json
@{
    "batchAccount"= @{
        "key"= $BATCH_ACCOUNT_KEY;
        "url"= "https://$BATCH_ACCOUNT_ENDPOINT";
        "name"= $NAME;
    };
    "storageAccount"= @{
        "key"= $STORAGE_ACCOUNT_KEY;
        "endpointSuffix"= $STORAGE_SUFFIX;
        "name"= $NAME;
    };
}| ConvertTo-Json 

Bonus: this works in your local powershell client if you have the az CLI tool installed. Similar code for bash and CMD can be found here.

@matthysk
Copy link

matthysk commented Jan 5, 2021

Same issue.

@jpredist
Copy link

yep, same issue here

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants