Closed phansys closed 8 years ago
I ran a simple test and getInstanceSize() returned a string "Small" which is the same as the value on the Azure Portal. See the following,
In this case, "Small" is 1792 MB. See the configuration in Visual Studio where I created this WebRole,
@yaqiyang, by instance, I can see "Basic A0 (0.25 Cores, 0.75 GB memory)" as size at Azure Portal; but the SDK is returning null
for that value as I mentioned before. Can you please check this situation directly with the SDK and the snippet I've provided?
Moreover, I need to access memoryInMB
and numberOfCores
properties. Could you please tell me how to access these values with the current SDK implementation?
Did more tests. It seems $hostedService->getDeployments() does not return anything. You have to use the following code to get a valid reference to deployment
$options = new GetDeploymentOptions();
$options->setDeploymentName($name);
$result = $this->restProxy->getDeployment($name, $options);
$deployment = $result->getDeployment();
Plus, I don't see any way to get the number of cores and VM size in MB. The VM size is probably defined in some templates. You have to map the enum (such as Small) to the corresponding true size (# core, MB) in the deployment templates.
Thanks for the feedback @yaqiyang. I've talked with the person who is working directly with this feature at my team and he told me that the check you proposed was already done with the same result. He has some suspicions about the issue, so I'll ask him to contact you tomorrow.
Thank you again.
/cc @ppicatto
Hi @yaqiyang as @phansys says i think that the problem is in the SDK because I have dumped $parsed
parameter from Role::create($parsed)
and it gives me "RoleSize" => "Basic_A0"
and i have seen that Role.php
have only 2 methods getRoleName
and getOsVersion
but I have seen a method RoleInstance::getInstanceSize()
that I believe should have the value returned in RoleSize
. I do not know if i should get instance size from RoleInstance
or there is another class that actually returns it.
Can you give me exact steps to re-create this role? I cannot reproduce the problem with the WebRole I created. The $parsed parameter in Role::create() has the following value in my example
array(2) { ["RoleName"]=> string(8) "WebRole1" ["OsVersion"]=> string(26) "WA-GUEST-OS-4.31_201604-01" }
There were some classes that we had overwritten in our code, so i decided to try to get the data directly from SDK but i get a null value in the following var_dump
:
$serviceManagementService = ServicesBuilder::getInstance()->createServiceManagementService(
sprintf('SubscriptionID=%s;CertificatePath=%s', $subscriptionId, $certificate)
);
$listHostedServices = $serviceManagementService->listHostedServices();
$hostedServicePropertiesOptions = new GetHostedServicePropertiesOptions();
$hostedServicePropertiesOptions->setEmbedDetail(true);
foreach ($listHostedServices as $listHostedService) {
$hostedServiceProperties = $serviceManagementService->getHostedServiceProperties(
$listHostedService->getName(),
$hostedServicePropertiesOptions
);
if ($hostedService = $hostedServiceProperties->getHostedService()) {
var_dump($hostedService->getDeployments()); //NULL
}
}
If I replace your code $lhs = $sb->listHostedServices(); with $lhs = $sb->listHostedServices()->getHostedServices(); It does work for me. I can get a valid list of deployments back with valid role instances and sizes. Can you try that?
Can you send me the deployment package and its config file for this service (.cspkg and .cscfg files for example)? I think the problem may be specific to the type of service/package you are trying to deploy.
Sorry for the delay in the answer @yaqiyang. I have tested with $serviceManagementService->listHostedServices()->getHostedServices();
and it doesn't work for me either. I do not have any files with extension .cspkg and .cscfg.
if you dump $hostedServiceProperties, do you get any valid properties there? All deployment data should be there
when I dump $hostedServiceProperties it returns:
object(WindowsAzure\ServiceManagement\Models\GetHostedServicePropertiesResult)#163 (1) {
["_hostedService":"WindowsAzure\ServiceManagement\Models\GetHostedServicePropertiesResult":private]=>
object(WindowsAzure\ServiceManagement\Models\HostedService)#156 (8) {
["_deployments":"WindowsAzure\ServiceManagement\Models\HostedService":private]=>
array(0) {
}
["_affinityGroup":"WindowsAzure\ServiceManagement\Internal\WindowsAzureService":private]=>
NULL
["_url":"WindowsAzure\ServiceManagement\Internal\WindowsAzureService":private]=>
string(111) "https://management.core.windows.net/{subscriptionId}/services/hostedservices/{cloudname}"
["_name":"WindowsAzure\ServiceManagement\Internal\Service":private]=>
string(14) "{cloudname}"
["_label":"WindowsAzure\ServiceManagement\Internal\Service":private]=>
string(20) "bnViaXR5LWh5cGVyLXY="
["_description":"WindowsAzure\ServiceManagement\Internal\Service":private]=>
NULL
["_location":"WindowsAzure\ServiceManagement\Internal\Service":private]=>
string(10) "Central US"
["_serializationProperties":"WindowsAzure\ServiceManagement\Internal\Service":private]=>
NULL
}
}
Here is the dump of the same variable for me. Your code did not return any deployment back. Do you have any Web roles or worker roles deployed? Another way to try is to use the following code to get the deployment,
$options = new GetDeploymentOptions();
$options->setDeploymentName($deploymentName);
$result = $this->restProxy->getDeployment($serviceName, $options);
$deployment = $result->getDeployment();
var_dump($hostedServiceProperties);
object(WindowsAzure\ServiceManagement\Models\GetHostedServicePropertiesResult)#46 (1) {
["_hostedService":"WindowsAzure\ServiceManagement\Models\GetHostedServicePropertiesResult":private]=>
object(WindowsAzure\ServiceManagement\Models\HostedService)#40 (8) {
["_deployments":"WindowsAzure\ServiceManagement\Models\HostedService":private]=>
array(1) {
[0]=>
object(WindowsAzure\ServiceManagement\Models\Deployment)#44 (15) {
["_name":"WindowsAzure\ServiceManagement\Models\Deployment":private]=>
string(32) "af0cb7ed22f746c18810c7628684fadb"
["_slot":"WindowsAzure\ServiceManagement\Models\Deployment":private]=>
string(10) "Production"
["_privateId":"WindowsAzure\ServiceManagement\Models\Deployment":private]=>
string(32) "ffea210869c64036b133de6af70334bc"
["_status":"WindowsAzure\ServiceManagement\Models\Deployment":private]=>
string(7) "Running"
["_label":"WindowsAzure\ServiceManagement\Models\Deployment":private]=>
string(12) "eWF5YXRlc3Qx"
I have tested what you requested and it throws the following exception:
[error] 21346#0: *49 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught exception 'WindowsAzure\Common\ServiceException' with message 'Fail:
Code: 404
Value: Not Found
details (if any): <Error xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Code>ResourceNotFound</Code><Message>No deployments were found.</Message></Error>.' in /home/ppicatto/Projects/azure-test/WindowsAzure/Common/Internal/Http/HttpClient.php:384
I have seen that the exception was because the instance was stopped i'll do more tests and talk you again.
just make sure the correct service name and deployment name
Well i have done some testings and the problem with $roleInstance->getInstanceSize()
was that the instance was stopped before testing. Now i need to get the memory and cores using the name for example "BASIC_A0" i do not find a way to get this data from the SDK.
I don't think that is possible. https://azure.microsoft.com/en-us/documentation/articles/cloud-services-sizes-specs/ Maybe you can define a mapping or find a defined mapping somewhere.
Thank you @yaqiyang. I think the only solution then will be to call another API endpoint in order to make a mapping between "size ID" and RAM / Cores. That endpoint is documented at List all available virtual machine sizes in a region. Do you know if this SDK has any method to consume that information?
I don't think we have that.
What are your concerns about this? Do you think it must be addressed by the SDK as a new feature? Or is it out if the scope and should be omitted?
I don't think we will add this functionality until we work on the new resource management SDK. The service management SDK does not have any VM management APIs implemented as far as I know.
Thank you so much @yaqiyang. Regards.
Given the following example, the instance sizes are always returning
null
:How can I get the instance sizes from service management? I need at least
memoryInMB
andnumberOfCores
properties. Thank you in advance.