Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.48k stars 4.81k forks source link

Role.OSVersion is null #562

Closed Rowdster closed 10 years ago

Rowdster commented 10 years ago

333 was supposedly resolved as of 0.9.4.

However, as of 0.9.7, when querying a "Windows Server 2012 Datacenter" machine, as of latest Nuget pull, 0.9.7, the below is returning null for role.OSVersion. The underlying REST API appears to be as "OsVersion".

        #region List VM
        public void ListVM()
        {
            ComputeManagementClient client = new ComputeManagementClient(_subscriptionCloudCredentials);
            var hostedServices = client.HostedServices.List();
            foreach (var service in hostedServices)
            {
                var deployment = GetAzureDeyployment(service.ServiceName, DeploymentSlot.Production);
                if (deployment != null)
                {
                    if (deployment.Roles.Count > 0)
                    {
                        foreach (var role in deployment.Roles)
                        {
                            if (role.RoleType == VirtualMachineRoleType.PersistentVMRole.ToString())
                            {
                                Console.WriteLine(role.RoleName);
                            }

                        }
                    }
                }
            }
        }

        private DeploymentGetResponse GetAzureDeyployment(string serviceName, DeploymentSlot slot)
        {
            ComputeManagementClient client = new ComputeManagementClient(_subscriptionCloudCredentials);
            try
            {
                return client.Deployments.GetBySlot(serviceName, slot);

            }
            catch (CloudException ex)
            {

                if (ex.ErrorCode == "ResourceNotFound")
                {
                    return null;
                }
                else
                {
                    throw ex;
                }
            }
        }
        #endregion
```<p><a href="https://github.com/Azure/azure-sdk-for-net/issues/562">https://github.com/Azure/azure-sdk-for-net/issues/562</a></p>
<!---@tfsbridge:{"tfsId":2065929}-->
singhkays commented 10 years ago

Adding @huangpf @hyonholee for fixing

huangpf commented 10 years ago

@Rowdster Only PaaS deployments have the 'OsVersion' param, but the VM deployment you created/referred to is an IaaS one.

huangpf commented 10 years ago

Please close this issue as it's actually not about element name or serialization.

Rowdster commented 10 years ago

@huangpf , Thanks, but I still am not certain as to why this parameter is not returning data. Is there information or documentation on the differences between PaaS vs IaaS for provisioning with the Azure API and why I could expect to not see a result for OsVersion, even though the property is part of the API?

Thank you!

huangpf commented 10 years ago

@Rowdster, for IaaS and PaaS deployments, they have different Create() APIs, but they share the same Get() API. From the service's perspective, they are two different designs, and by design IaaS deployment roles won't have any values returned for this field.

@singhkay, could you please provide more information about the different designs?

References: PaaS Create Deployment: http://msdn.microsoft.com/en-us/library/azure/ee460813.aspx IaaS Create Deployment: http://msdn.microsoft.com/en-us/library/azure/jj157194.aspx IaaS/PaaS Get Deployment: http://msdn.microsoft.com/en-us/library/azure/ee460804.aspx IaaS Get Role: http://msdn.microsoft.com/en-us/library/azure/jj157193.aspx