GET https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-4799/providers/Microsoft.Sql/servers/sqlcrudtest-5961/databases/testdw/geoBackupPolicies/Default?api-version=2014-04-01
import com.azure.core.util.Context;
import com.azure.resourcemanager.sql.models.GeoBackupPolicyName;
/** Samples for GeoBackupPolicies Get. */
public final class Main {
/*
* x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/GeoBackupPoliciesGet.json
*/
/**
* Sample code: Get geo backup policy.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void getGeoBackupPolicy(com.azure.resourcemanager.AzureResourceManager azure) {
azure
.sqlServers()
.manager()
.serviceClient()
.getGeoBackupPolicies()
.getWithResponse(
"sqlcrudtest-4799", "sqlcrudtest-5961", "testdw", GeoBackupPolicyName.DEFAULT, Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python geo_backup_policies_get.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = SqlManagementClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-1111-2222-3333-444444444444",
)
response = client.geo_backup_policies.get(
resource_group_name="sqlcrudtest-4799",
server_name="sqlcrudtest-5961",
database_name="testdw",
geo_backup_policy_name="Default",
)
print(response)
# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/GeoBackupPoliciesGet.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armsql_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/sql/armsql/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a3913f4b26467aed413cdc907116e99894f08994/specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/GeoBackupPoliciesGet.json
func ExampleGeoBackupPoliciesClient_Get() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armsql.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewGeoBackupPoliciesClient().Get(ctx, "sqlcrudtest-4799", "sqlcrudtest-5961", "testdw", armsql.GeoBackupPolicyNameDefault, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.GeoBackupPolicy = armsql.GeoBackupPolicy{
// Name: to.Ptr("Default"),
// Type: to.Ptr("Microsoft.Sql/servers/databases/geoBackupPolicies"),
// ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-4799/providers/Microsoft.Sql/servers/sqlcrudtest-5961/databases/testdw/geoBackupPolicies/Default"),
// Location: to.Ptr("Central US"),
// Properties: &armsql.GeoBackupPolicyProperties{
// State: to.Ptr(armsql.GeoBackupPolicyStateEnabled),
// StorageType: to.Ptr("Premium"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Gets a geo backup policy.
*
* @summary Gets a geo backup policy.
* x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/GeoBackupPoliciesGet.json
*/
async function getGeoBackupPolicy() {
const subscriptionId =
process.env["SQL_SUBSCRIPTION_ID"] || "00000000-1111-2222-3333-444444444444";
const resourceGroupName = process.env["SQL_RESOURCE_GROUP"] || "sqlcrudtest-4799";
const serverName = "sqlcrudtest-5961";
const databaseName = "testdw";
const geoBackupPolicyName = "Default";
const credential = new DefaultAzureCredential();
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.geoBackupPolicies.get(
resourceGroupName,
serverName,
databaseName,
geoBackupPolicyName,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Sql.Models;
using Azure.ResourceManager.Sql;
// Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/GeoBackupPoliciesGet.json
// this example is just showing the usage of "GeoBackupPolicies_Get" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this GeoBackupPolicyResource created on azure
// for more information of creating GeoBackupPolicyResource, please refer to the document of GeoBackupPolicyResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "sqlcrudtest-4799";
string serverName = "sqlcrudtest-5961";
string databaseName = "testdw";
GeoBackupPolicyName geoBackupPolicyName = GeoBackupPolicyName.Default;
ResourceIdentifier geoBackupPolicyResourceId = GeoBackupPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, geoBackupPolicyName);
GeoBackupPolicyResource geoBackupPolicy = client.GetGeoBackupPolicyResource(geoBackupPolicyResourceId);
// invoke the operation
GeoBackupPolicyResource result = await geoBackupPolicy.GetAsync();
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
GeoBackupPolicyData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue