Creates a deployment script.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}?api-version=2020-10-01
Expand table
Name
In
Required
Type
Description
resourceGroupName
path
True
string
minLength: 1 maxLength: 90
The name of the resource group. The name is case insensitive.
scriptName
path
True
string
minLength: 1 maxLength: 90
Name of the deployment script.
subscriptionId
path
True
string
Subscription Id which forms part of the URI for every service call.
api-version
query
True
string
Client Api version.
The request body can be one of the following:
Expand table
Object model for the Azure CLI script.
Expand table
Name
Required
Type
Description
kind
True
string:
AzureCLI
Type of the script.
location
True
string
The location of the ACI and the storage account for the deployment script.
properties.azCliVersion
True
string
Azure CLI module version to be used.
properties.retentionInterval
True
string
(duration)
Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day).
identity
ManagedServiceIdentity
Optional property. Managed identity to be used for this deployment script. Currently, only user-assigned MSI is supported.
properties.arguments
string
Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'
properties.cleanupPreference
cleanupOptions
The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'.
properties.containerSettings
ContainerConfiguration
Container settings.
properties.environmentVariables
EnvironmentVariable []
The environment variables to pass over to the script.
properties.forceUpdateTag
string
Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID.
properties.primaryScriptUri
string
Uri for the script. This is the entry point for the external script.
properties.scriptContent
string
Script body.
properties.storageAccountSettings
StorageAccountConfiguration
Storage Account settings.
properties.supportingScriptUris
string[]
Supporting files for the external script.
properties.timeout
string
(duration)
Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D
tags
object
Resource tags.
Object model for the Azure PowerShell script.
Expand table
Name
Required
Type
Description
kind
True
string:
AzurePowerShell
Type of the script.
location
True
string
The location of the ACI and the storage account for the deployment script.
properties.azPowerShellVersion
True
string
Azure PowerShell module version to be used.
properties.retentionInterval
True
string
(duration)
Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day).
identity
ManagedServiceIdentity
Optional property. Managed identity to be used for this deployment script. Currently, only user-assigned MSI is supported.
properties.arguments
string
Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'
properties.cleanupPreference
cleanupOptions
The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'.
properties.containerSettings
ContainerConfiguration
Container settings.
properties.environmentVariables
EnvironmentVariable []
The environment variables to pass over to the script.
properties.forceUpdateTag
string
Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID.
properties.primaryScriptUri
string
Uri for the script. This is the entry point for the external script.
properties.scriptContent
string
Script body.
properties.storageAccountSettings
StorageAccountConfiguration
Storage Account settings.
properties.supportingScriptUris
string[]
Supporting files for the external script.
properties.timeout
string
(duration)
Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D
tags
object
Resource tags.
Expand table
Name
Type
Description
200 OK
DeploymentScript:
OK -- Deployment script is updated.
201 Created
DeploymentScript:
Created -- Deployment script created.
Other Status Codes
DeploymentScriptsError
Error response describing why the operation failed.
Azure Active Directory OAuth2 Flow
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Expand table
Name
Description
user_impersonation
impersonate your user account
Expand table
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/script-rg/providers/Microsoft.Resources/deploymentScripts/MyDeploymentScript?api-version=2020-10-01
{
"kind": "AzurePowerShell",
"location": "westus",
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {}
}
},
"properties": {
"azPowerShellVersion": "1.7.0",
"scriptContent": "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
"arguments": "-Location 'westus' -Name \"*rg2\"",
"supportingScriptUris": [
"https://uri1.to.supporting.script",
"https://uri2.to.supporting.script"
],
"retentionInterval": "PT7D",
"timeout": "PT1H",
"cleanupPreference": "Always"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.resource import DeploymentScriptsClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-resource
# USAGE
python deployment_scripts_create.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 = DeploymentScriptsClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.deployment_scripts.begin_create(
resource_group_name="script-rg",
script_name="MyDeploymentScript",
deployment_script={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {}
},
},
"kind": "AzurePowerShell",
"location": "westus",
"properties": {
"arguments": "-Location 'westus' -Name \"*rg2\"",
"azPowerShellVersion": "1.7.0",
"cleanupPreference": "Always",
"retentionInterval": "PT7D",
"scriptContent": "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
"supportingScriptUris": ["https://uri1.to.supporting.script", "https://uri2.to.supporting.script"],
"timeout": "PT1H",
},
},
).result()
print(response)
# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Create.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 armdeploymentscripts_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armdeploymentscripts/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Create.json
func ExampleClient_BeginCreate_deploymentScriptsCreate() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armdeploymentscripts.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClient().BeginCreate(ctx, "script-rg", "MyDeploymentScript", &armdeploymentscripts.AzurePowerShellScript{
Identity: &armdeploymentscripts.ManagedServiceIdentity{
Type: to.Ptr(armdeploymentscripts.ManagedServiceIdentityTypeUserAssigned),
UserAssignedIdentities: map[string]*armdeploymentscripts.UserAssignedIdentity{
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {},
},
},
Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell),
Location: to.Ptr("westus"),
Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{
CleanupPreference: to.Ptr(armdeploymentscripts.CleanupOptionsAlways),
Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""),
RetentionInterval: to.Ptr("PT7D"),
ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"),
SupportingScriptUris: []*string{
to.Ptr("https://uri1.to.supporting.script"),
to.Ptr("https://uri2.to.supporting.script")},
Timeout: to.Ptr("PT1H"),
AzPowerShellVersion: to.Ptr("1.7.0"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %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 = armdeploymentscripts.ClientCreateResponse{
// DeploymentScriptClassification: &armdeploymentscripts.AzurePowerShellScript{
// Identity: &armdeploymentscripts.ManagedServiceIdentity{
// Type: to.Ptr(armdeploymentscripts.ManagedServiceIdentityTypeUserAssigned),
// UserAssignedIdentities: map[string]*armdeploymentscripts.UserAssignedIdentity{
// "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": &armdeploymentscripts.UserAssignedIdentity{
// },
// },
// },
// Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell),
// Location: to.Ptr("westus"),
// Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{
// CleanupPreference: to.Ptr(armdeploymentscripts.CleanupOptionsAlways),
// Outputs: map[string]any{
// "output1": "value1",
// },
// ProvisioningState: to.Ptr(armdeploymentscripts.ScriptProvisioningStateSucceeded),
// Status: &armdeploymentscripts.ScriptStatus{
// ContainerInstanceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer"),
// EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()),
// ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()),
// StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()),
// StorageAccountID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage"),
// },
// Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""),
// RetentionInterval: to.Ptr("P7D"),
// ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"),
// SupportingScriptUris: []*string{
// to.Ptr("https://uri1.to.supporting.script"),
// to.Ptr("https://uri2.to.supporting.script")},
// Timeout: to.Ptr("PT1H"),
// AzPowerShellVersion: to.Ptr("1.7.0"),
// },
// },
// }
}
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 System.Xml;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Create.json
// this example is just showing the usage of "DeploymentScripts_Create" 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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "00000000-0000-0000-0000-000000000000";
string resourceGroupName = "script-rg";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ArmDeploymentScriptResource
ArmDeploymentScriptCollection collection = resourceGroupResource.GetArmDeploymentScripts();
// invoke the operation
string scriptName = "MyDeploymentScript";
ArmDeploymentScriptData data = new AzurePowerShellScript(new AzureLocation("westus"), XmlConvert.ToTimeSpan("PT7D"), "1.7.0")
{
CleanupPreference = ScriptCleanupOptions.Always,
SupportingScriptUris = { new Uri("https://uri1.to.supporting.script"), new Uri("https://uri2.to.supporting.script") },
ScriptContent = "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
Arguments = "-Location 'westus' -Name \"*rg2\"",
Timeout = XmlConvert.ToTimeSpan("PT1H"),
Identity = new ArmDeploymentScriptManagedIdentity
{
IdentityType = ArmDeploymentScriptManagedIdentityType.UserAssigned,
UserAssignedIdentities =
{
["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai"] = new UserAssignedIdentity()
},
},
};
ArmOperation<ArmDeploymentScriptResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scriptName, data);
ArmDeploymentScriptResource result = lro.Value;
// 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
ArmDeploymentScriptData 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
Sample response
{
"kind": "AzurePowerShell",
"location": "westus",
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {}
}
},
"systemData": {
"createdBy": "string",
"createdByType": "Application",
"createdAt": "2020-02-01T01:01:01.1075056Z",
"lastModifiedBy": "string",
"lastModifiedByType": "Application",
"lastModifiedAt": "2020-02-01T01:01:01.1075056Z"
},
"properties": {
"provisioningState": "Creating",
"azPowerShellVersion": "1.7.0",
"scriptContent": "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
"arguments": "-Location 'westus' -Name \"*rg2\"",
"supportingScriptUris": [
"https://uri1.to.supporting.script",
"https://uri2.to.supporting.script"
],
"retentionInterval": "P7D",
"timeout": "PT1H",
"cleanupPreference": "Always",
"status": {
"containerInstanceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer",
"storageAccountId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage",
"startTime": "2018-11-13T15:19:45-08:00",
"endTime": "2018-11-13T15:19:45-08:00",
"expirationTime": "2018-11-13T15:19:45-08:00"
}
}
}
{
"kind": "AzurePowerShell",
"location": "westus",
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {}
}
},
"properties": {
"provisioningState": "Succeeded",
"azPowerShellVersion": "1.7.0",
"scriptContent": "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
"arguments": "-Location 'westus' -Name \"*rg2\"",
"supportingScriptUris": [
"https://uri1.to.supporting.script",
"https://uri2.to.supporting.script"
],
"retentionInterval": "P7D",
"timeout": "PT1H",
"cleanupPreference": "Always",
"status": {
"containerInstanceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer",
"storageAccountId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage",
"startTime": "2018-11-13T15:19:45-08:00",
"endTime": "2018-11-13T15:19:45-08:00",
"expirationTime": "2018-11-13T15:19:45-08:00"
},
"outputs": {
"output1": "value1"
}
}
}
DeploymentScriptsCreate_MinCreate
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/script-rg/providers/Microsoft.Resources/deploymentScripts/MyDeploymentScript?api-version=2020-10-01
{
"kind": "AzurePowerShell",
"location": "westus",
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {}
}
},
"properties": {
"azPowerShellVersion": "1.7.0",
"scriptContent": "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
"arguments": "-Location 'westus' -Name \"*rg2\"",
"retentionInterval": "P7D"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.resource import DeploymentScriptsClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-resource
# USAGE
python deployment_scripts_min_create.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 = DeploymentScriptsClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.deployment_scripts.begin_create(
resource_group_name="script-rg",
script_name="MyDeploymentScript",
deployment_script={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {}
},
},
"kind": "AzurePowerShell",
"location": "westus",
"properties": {
"arguments": "-Location 'westus' -Name \"*rg2\"",
"azPowerShellVersion": "1.7.0",
"retentionInterval": "P7D",
"scriptContent": "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
},
},
).result()
print(response)
# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Min_Create.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 armdeploymentscripts_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armdeploymentscripts/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Min_Create.json
func ExampleClient_BeginCreate_deploymentScriptsCreateMinCreate() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armdeploymentscripts.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClient().BeginCreate(ctx, "script-rg", "MyDeploymentScript", &armdeploymentscripts.AzurePowerShellScript{
Identity: &armdeploymentscripts.ManagedServiceIdentity{
Type: to.Ptr(armdeploymentscripts.ManagedServiceIdentityTypeUserAssigned),
UserAssignedIdentities: map[string]*armdeploymentscripts.UserAssignedIdentity{
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {},
},
},
Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell),
Location: to.Ptr("westus"),
Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{
Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""),
RetentionInterval: to.Ptr("P7D"),
ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"),
AzPowerShellVersion: to.Ptr("1.7.0"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %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 = armdeploymentscripts.ClientCreateResponse{
// DeploymentScriptClassification: &armdeploymentscripts.AzurePowerShellScript{
// Identity: &armdeploymentscripts.ManagedServiceIdentity{
// Type: to.Ptr(armdeploymentscripts.ManagedServiceIdentityTypeUserAssigned),
// UserAssignedIdentities: map[string]*armdeploymentscripts.UserAssignedIdentity{
// "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": &armdeploymentscripts.UserAssignedIdentity{
// },
// },
// },
// Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell),
// Location: to.Ptr("westus"),
// Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{
// CleanupPreference: to.Ptr(armdeploymentscripts.CleanupOptionsAlways),
// Outputs: map[string]any{
// "output1": "value1",
// },
// ProvisioningState: to.Ptr(armdeploymentscripts.ScriptProvisioningStateSucceeded),
// Status: &armdeploymentscripts.ScriptStatus{
// ContainerInstanceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer"),
// EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()),
// ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()),
// StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()),
// StorageAccountID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage"),
// },
// Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""),
// RetentionInterval: to.Ptr("P7D"),
// ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"),
// Timeout: to.Ptr("PT1H"),
// AzPowerShellVersion: to.Ptr("1.7.0"),
// },
// },
// }
}
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 System.Xml;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Min_Create.json
// this example is just showing the usage of "DeploymentScripts_Create" 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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "00000000-0000-0000-0000-000000000000";
string resourceGroupName = "script-rg";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ArmDeploymentScriptResource
ArmDeploymentScriptCollection collection = resourceGroupResource.GetArmDeploymentScripts();
// invoke the operation
string scriptName = "MyDeploymentScript";
ArmDeploymentScriptData data = new AzurePowerShellScript(new AzureLocation("westus"), XmlConvert.ToTimeSpan("P7D"), "1.7.0")
{
ScriptContent = "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
Arguments = "-Location 'westus' -Name \"*rg2\"",
Identity = new ArmDeploymentScriptManagedIdentity
{
IdentityType = ArmDeploymentScriptManagedIdentityType.UserAssigned,
UserAssignedIdentities =
{
["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai"] = new UserAssignedIdentity()
},
},
};
ArmOperation<ArmDeploymentScriptResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scriptName, data);
ArmDeploymentScriptResource result = lro.Value;
// 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
ArmDeploymentScriptData 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
Sample response
{
"kind": "AzurePowerShell",
"location": "westus",
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {}
}
},
"systemData": {
"createdBy": "string",
"createdByType": "Application",
"createdAt": "2020-02-01T01:01:01.1075056Z",
"lastModifiedBy": "string",
"lastModifiedByType": "Application",
"lastModifiedAt": "2020-02-01T01:01:01.1075056Z"
},
"properties": {
"provisioningState": "Creating",
"azPowerShellVersion": "1.7.0",
"scriptContent": "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
"arguments": "-Location 'westus' -Name \"*rg2\"",
"retentionInterval": "P7D",
"timeout": "PT1H",
"cleanupPreference": "Always",
"status": {
"containerInstanceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer",
"storageAccountId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage",
"startTime": "2018-11-13T15:19:45-08:00",
"endTime": "2018-11-13T15:19:45-08:00",
"expirationTime": "2018-11-13T15:19:45-08:00"
}
}
}
{
"kind": "AzurePowerShell",
"location": "westus",
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {}
}
},
"properties": {
"provisioningState": "Succeeded",
"azPowerShellVersion": "1.7.0",
"scriptContent": "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
"arguments": "-Location 'westus' -Name \"*rg2\"",
"retentionInterval": "P7D",
"timeout": "PT1H",
"cleanupPreference": "Always",
"status": {
"containerInstanceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer",
"storageAccountId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage",
"startTime": "2018-11-13T15:19:45-08:00",
"endTime": "2018-11-13T15:19:45-08:00",
"expirationTime": "2018-11-13T15:19:45-08:00"
},
"outputs": {
"output1": "value1"
}
}
}
DeploymentScriptsCreate_UsingCustomACIName
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/script-rg/providers/Microsoft.Resources/deploymentScripts/MyDeploymentScript?api-version=2020-10-01
{
"kind": "AzurePowerShell",
"location": "westus",
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {}
}
},
"properties": {
"azPowerShellVersion": "1.7.0",
"scriptContent": "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
"containerSettings": {
"containerGroupName": "contoso-aci"
},
"arguments": "-Location 'westus' -Name \"*rg2\"",
"supportingScriptUris": [
"https://uri1.to.supporting.script",
"https://uri2.to.supporting.script"
],
"retentionInterval": "PT7D",
"timeout": "PT1H",
"cleanupPreference": "Always"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.resource import DeploymentScriptsClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-resource
# USAGE
python deployment_scripts_create_using_custom_aci_name.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 = DeploymentScriptsClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.deployment_scripts.begin_create(
resource_group_name="script-rg",
script_name="MyDeploymentScript",
deployment_script={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {}
},
},
"kind": "AzurePowerShell",
"location": "westus",
"properties": {
"arguments": "-Location 'westus' -Name \"*rg2\"",
"azPowerShellVersion": "1.7.0",
"cleanupPreference": "Always",
"containerSettings": {"containerGroupName": "contoso-aci"},
"retentionInterval": "PT7D",
"scriptContent": "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
"supportingScriptUris": ["https://uri1.to.supporting.script", "https://uri2.to.supporting.script"],
"timeout": "PT1H",
},
},
).result()
print(response)
# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Create_Using_Custom_Aci_Name.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 armdeploymentscripts_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armdeploymentscripts/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Create_Using_Custom_Aci_Name.json
func ExampleClient_BeginCreate_deploymentScriptsCreateUsingCustomAciName() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armdeploymentscripts.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClient().BeginCreate(ctx, "script-rg", "MyDeploymentScript", &armdeploymentscripts.AzurePowerShellScript{
Identity: &armdeploymentscripts.ManagedServiceIdentity{
Type: to.Ptr(armdeploymentscripts.ManagedServiceIdentityTypeUserAssigned),
UserAssignedIdentities: map[string]*armdeploymentscripts.UserAssignedIdentity{
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {},
},
},
Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell),
Location: to.Ptr("westus"),
Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{
CleanupPreference: to.Ptr(armdeploymentscripts.CleanupOptionsAlways),
ContainerSettings: &armdeploymentscripts.ContainerConfiguration{
ContainerGroupName: to.Ptr("contoso-aci"),
},
Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""),
RetentionInterval: to.Ptr("PT7D"),
ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"),
SupportingScriptUris: []*string{
to.Ptr("https://uri1.to.supporting.script"),
to.Ptr("https://uri2.to.supporting.script")},
Timeout: to.Ptr("PT1H"),
AzPowerShellVersion: to.Ptr("1.7.0"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %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 = armdeploymentscripts.ClientCreateResponse{
// DeploymentScriptClassification: &armdeploymentscripts.AzurePowerShellScript{
// Identity: &armdeploymentscripts.ManagedServiceIdentity{
// Type: to.Ptr(armdeploymentscripts.ManagedServiceIdentityTypeUserAssigned),
// UserAssignedIdentities: map[string]*armdeploymentscripts.UserAssignedIdentity{
// "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": &armdeploymentscripts.UserAssignedIdentity{
// },
// },
// },
// Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell),
// Location: to.Ptr("westus"),
// Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{
// CleanupPreference: to.Ptr(armdeploymentscripts.CleanupOptionsAlways),
// ContainerSettings: &armdeploymentscripts.ContainerConfiguration{
// ContainerGroupName: to.Ptr("contoso-aci"),
// },
// Outputs: map[string]any{
// "output1": "value1",
// },
// ProvisioningState: to.Ptr(armdeploymentscripts.ScriptProvisioningStateSucceeded),
// Status: &armdeploymentscripts.ScriptStatus{
// ContainerInstanceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer"),
// EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()),
// ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()),
// StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()),
// StorageAccountID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage"),
// },
// Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""),
// RetentionInterval: to.Ptr("P7D"),
// ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"),
// SupportingScriptUris: []*string{
// to.Ptr("https://uri1.to.supporting.script"),
// to.Ptr("https://uri2.to.supporting.script")},
// Timeout: to.Ptr("PT1H"),
// AzPowerShellVersion: to.Ptr("1.7.0"),
// },
// },
// }
}
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 System.Xml;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Create_Using_Custom_Aci_Name.json
// this example is just showing the usage of "DeploymentScripts_Create" 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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "00000000-0000-0000-0000-000000000000";
string resourceGroupName = "script-rg";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ArmDeploymentScriptResource
ArmDeploymentScriptCollection collection = resourceGroupResource.GetArmDeploymentScripts();
// invoke the operation
string scriptName = "MyDeploymentScript";
ArmDeploymentScriptData data = new AzurePowerShellScript(new AzureLocation("westus"), XmlConvert.ToTimeSpan("PT7D"), "1.7.0")
{
ContainerGroupName = "contoso-aci",
CleanupPreference = ScriptCleanupOptions.Always,
SupportingScriptUris = { new Uri("https://uri1.to.supporting.script"), new Uri("https://uri2.to.supporting.script") },
ScriptContent = "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
Arguments = "-Location 'westus' -Name \"*rg2\"",
Timeout = XmlConvert.ToTimeSpan("PT1H"),
Identity = new ArmDeploymentScriptManagedIdentity
{
IdentityType = ArmDeploymentScriptManagedIdentityType.UserAssigned,
UserAssignedIdentities =
{
["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai"] = new UserAssignedIdentity()
},
},
};
ArmOperation<ArmDeploymentScriptResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scriptName, data);
ArmDeploymentScriptResource result = lro.Value;
// 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
ArmDeploymentScriptData 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
Sample response
{
"kind": "AzurePowerShell",
"location": "westus",
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {}
}
},
"systemData": {
"createdBy": "string",
"createdByType": "Application",
"createdAt": "2020-02-01T01:01:01.1075056Z",
"lastModifiedBy": "string",
"lastModifiedByType": "Application",
"lastModifiedAt": "2020-02-01T01:01:01.1075056Z"
},
"properties": {
"provisioningState": "Creating",
"azPowerShellVersion": "1.7.0",
"scriptContent": "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
"arguments": "-Location 'westus' -Name \"*rg2\"",
"supportingScriptUris": [
"https://uri1.to.supporting.script",
"https://uri2.to.supporting.script"
],
"retentionInterval": "P7D",
"timeout": "PT1H",
"containerSettings": {
"containerGroupName": "contoso-aci"
},
"cleanupPreference": "Always",
"status": {
"containerInstanceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer",
"storageAccountId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage",
"startTime": "2018-11-13T15:19:45-08:00",
"endTime": "2018-11-13T15:19:45-08:00",
"expirationTime": "2018-11-13T15:19:45-08:00"
}
}
}
{
"kind": "AzurePowerShell",
"location": "westus",
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {}
}
},
"properties": {
"provisioningState": "Succeeded",
"azPowerShellVersion": "1.7.0",
"scriptContent": "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
"arguments": "-Location 'westus' -Name \"*rg2\"",
"supportingScriptUris": [
"https://uri1.to.supporting.script",
"https://uri2.to.supporting.script"
],
"retentionInterval": "P7D",
"timeout": "PT1H",
"containerSettings": {
"containerGroupName": "contoso-aci"
},
"cleanupPreference": "Always",
"status": {
"containerInstanceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer",
"storageAccountId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage",
"startTime": "2018-11-13T15:19:45-08:00",
"endTime": "2018-11-13T15:19:45-08:00",
"expirationTime": "2018-11-13T15:19:45-08:00"
},
"outputs": {
"output1": "value1"
}
}
}
DeploymentScriptsCreate_UsingExistingStorageAccount
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/script-rg/providers/Microsoft.Resources/deploymentScripts/MyDeploymentScript?api-version=2020-10-01
{
"kind": "AzurePowerShell",
"location": "westus",
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {}
}
},
"properties": {
"azPowerShellVersion": "1.7.0",
"scriptContent": "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
"storageAccountSettings": {
"storageAccountName": "contosostorage",
"storageAccountKey": "contosostoragekey"
},
"arguments": "-Location 'westus' -Name \"*rg2\"",
"supportingScriptUris": [
"https://uri1.to.supporting.script",
"https://uri2.to.supporting.script"
],
"retentionInterval": "PT7D",
"timeout": "PT1H",
"cleanupPreference": "Always"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.resource import DeploymentScriptsClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-resource
# USAGE
python deployment_scripts_create_using_existing_storage_account.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 = DeploymentScriptsClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.deployment_scripts.begin_create(
resource_group_name="script-rg",
script_name="MyDeploymentScript",
deployment_script={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {}
},
},
"kind": "AzurePowerShell",
"location": "westus",
"properties": {
"arguments": "-Location 'westus' -Name \"*rg2\"",
"azPowerShellVersion": "1.7.0",
"cleanupPreference": "Always",
"retentionInterval": "PT7D",
"scriptContent": "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
"storageAccountSettings": {
"storageAccountKey": "contosostoragekey",
"storageAccountName": "contosostorage",
},
"supportingScriptUris": ["https://uri1.to.supporting.script", "https://uri2.to.supporting.script"],
"timeout": "PT1H",
},
},
).result()
print(response)
# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Create_Using_Existing_StorageAccount.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 armdeploymentscripts_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armdeploymentscripts/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Create_Using_Existing_StorageAccount.json
func ExampleClient_BeginCreate_deploymentScriptsCreateUsingExistingStorageAccount() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armdeploymentscripts.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClient().BeginCreate(ctx, "script-rg", "MyDeploymentScript", &armdeploymentscripts.AzurePowerShellScript{
Identity: &armdeploymentscripts.ManagedServiceIdentity{
Type: to.Ptr(armdeploymentscripts.ManagedServiceIdentityTypeUserAssigned),
UserAssignedIdentities: map[string]*armdeploymentscripts.UserAssignedIdentity{
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {},
},
},
Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell),
Location: to.Ptr("westus"),
Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{
CleanupPreference: to.Ptr(armdeploymentscripts.CleanupOptionsAlways),
StorageAccountSettings: &armdeploymentscripts.StorageAccountConfiguration{
StorageAccountKey: to.Ptr("contosostoragekey"),
StorageAccountName: to.Ptr("contosostorage"),
},
Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""),
RetentionInterval: to.Ptr("PT7D"),
ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"),
SupportingScriptUris: []*string{
to.Ptr("https://uri1.to.supporting.script"),
to.Ptr("https://uri2.to.supporting.script")},
Timeout: to.Ptr("PT1H"),
AzPowerShellVersion: to.Ptr("1.7.0"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %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 = armdeploymentscripts.ClientCreateResponse{
// DeploymentScriptClassification: &armdeploymentscripts.AzurePowerShellScript{
// Identity: &armdeploymentscripts.ManagedServiceIdentity{
// Type: to.Ptr(armdeploymentscripts.ManagedServiceIdentityTypeUserAssigned),
// UserAssignedIdentities: map[string]*armdeploymentscripts.UserAssignedIdentity{
// "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": &armdeploymentscripts.UserAssignedIdentity{
// },
// },
// },
// Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell),
// Location: to.Ptr("westus"),
// Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{
// CleanupPreference: to.Ptr(armdeploymentscripts.CleanupOptionsAlways),
// Outputs: map[string]any{
// "output1": "value1",
// },
// ProvisioningState: to.Ptr(armdeploymentscripts.ScriptProvisioningStateSucceeded),
// Status: &armdeploymentscripts.ScriptStatus{
// ContainerInstanceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer"),
// EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()),
// ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()),
// StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()),
// StorageAccountID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage"),
// },
// StorageAccountSettings: &armdeploymentscripts.StorageAccountConfiguration{
// StorageAccountName: to.Ptr("contosostorage"),
// },
// Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""),
// RetentionInterval: to.Ptr("P7D"),
// ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"),
// SupportingScriptUris: []*string{
// to.Ptr("https://uri1.to.supporting.script"),
// to.Ptr("https://uri2.to.supporting.script")},
// Timeout: to.Ptr("PT1H"),
// AzPowerShellVersion: to.Ptr("1.7.0"),
// },
// },
// }
}
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 System.Xml;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Create_Using_Existing_StorageAccount.json
// this example is just showing the usage of "DeploymentScripts_Create" 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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "00000000-0000-0000-0000-000000000000";
string resourceGroupName = "script-rg";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ArmDeploymentScriptResource
ArmDeploymentScriptCollection collection = resourceGroupResource.GetArmDeploymentScripts();
// invoke the operation
string scriptName = "MyDeploymentScript";
ArmDeploymentScriptData data = new AzurePowerShellScript(new AzureLocation("westus"), XmlConvert.ToTimeSpan("PT7D"), "1.7.0")
{
StorageAccountSettings = new ScriptStorageConfiguration
{
StorageAccountName = "contosostorage",
StorageAccountKey = "contosostoragekey",
},
CleanupPreference = ScriptCleanupOptions.Always,
SupportingScriptUris = { new Uri("https://uri1.to.supporting.script"), new Uri("https://uri2.to.supporting.script") },
ScriptContent = "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
Arguments = "-Location 'westus' -Name \"*rg2\"",
Timeout = XmlConvert.ToTimeSpan("PT1H"),
Identity = new ArmDeploymentScriptManagedIdentity
{
IdentityType = ArmDeploymentScriptManagedIdentityType.UserAssigned,
UserAssignedIdentities =
{
["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai"] = new UserAssignedIdentity()
},
},
};
ArmOperation<ArmDeploymentScriptResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scriptName, data);
ArmDeploymentScriptResource result = lro.Value;
// 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
ArmDeploymentScriptData 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
Sample response
{
"kind": "AzurePowerShell",
"location": "westus",
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {}
}
},
"systemData": {
"createdBy": "string",
"createdByType": "Application",
"createdAt": "2020-02-01T01:01:01.1075056Z",
"lastModifiedBy": "string",
"lastModifiedByType": "Application",
"lastModifiedAt": "2020-02-01T01:01:01.1075056Z"
},
"properties": {
"provisioningState": "Creating",
"azPowerShellVersion": "1.7.0",
"scriptContent": "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
"arguments": "-Location 'westus' -Name \"*rg2\"",
"supportingScriptUris": [
"https://uri1.to.supporting.script",
"https://uri2.to.supporting.script"
],
"storageAccountSettings": {
"storageAccountName": "contosostorage"
},
"retentionInterval": "P7D",
"timeout": "PT1H",
"cleanupPreference": "Always",
"status": {
"containerInstanceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer",
"storageAccountId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage",
"startTime": "2018-11-13T15:19:45-08:00",
"endTime": "2018-11-13T15:19:45-08:00",
"expirationTime": "2018-11-13T15:19:45-08:00"
}
}
}
{
"kind": "AzurePowerShell",
"location": "westus",
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {}
}
},
"properties": {
"provisioningState": "Succeeded",
"azPowerShellVersion": "1.7.0",
"scriptContent": "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
"arguments": "-Location 'westus' -Name \"*rg2\"",
"supportingScriptUris": [
"https://uri1.to.supporting.script",
"https://uri2.to.supporting.script"
],
"storageAccountSettings": {
"storageAccountName": "contosostorage"
},
"retentionInterval": "P7D",
"timeout": "PT1H",
"cleanupPreference": "Always",
"status": {
"containerInstanceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer",
"storageAccountId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage",
"startTime": "2018-11-13T15:19:45-08:00",
"endTime": "2018-11-13T15:19:45-08:00",
"expirationTime": "2018-11-13T15:19:45-08:00"
},
"outputs": {
"output1": "value1"
}
}
}
DeploymentScriptsCreateNoUserManagedIdentity
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/script-rg/providers/Microsoft.Resources/deploymentScripts/MyDeploymentScript?api-version=2020-10-01
{
"kind": "AzurePowerShell",
"location": "westus",
"properties": {
"azPowerShellVersion": "1.7.0",
"scriptContent": "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
"arguments": "-Location 'westus' -Name \"*rg2\"",
"supportingScriptUris": [
"https://uri1.to.supporting.script",
"https://uri2.to.supporting.script"
],
"retentionInterval": "PT7D",
"timeout": "PT1H",
"cleanupPreference": "Always"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.resource import DeploymentScriptsClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-resource
# USAGE
python deployment_scripts_create_no_user_managed_identity.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 = DeploymentScriptsClient(
credential=DefaultAzureCredential(),
subscription_id="00000000-0000-0000-0000-000000000000",
)
response = client.deployment_scripts.begin_create(
resource_group_name="script-rg",
script_name="MyDeploymentScript",
deployment_script={
"kind": "AzurePowerShell",
"location": "westus",
"properties": {
"arguments": "-Location 'westus' -Name \"*rg2\"",
"azPowerShellVersion": "1.7.0",
"cleanupPreference": "Always",
"retentionInterval": "PT7D",
"scriptContent": "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
"supportingScriptUris": ["https://uri1.to.supporting.script", "https://uri2.to.supporting.script"],
"timeout": "PT1H",
},
},
).result()
print(response)
# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Create_No_UserManagedIdentity.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 armdeploymentscripts_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armdeploymentscripts/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Create_No_UserManagedIdentity.json
func ExampleClient_BeginCreate_deploymentScriptsCreateNoUserManagedIdentity() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armdeploymentscripts.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClient().BeginCreate(ctx, "script-rg", "MyDeploymentScript", &armdeploymentscripts.AzurePowerShellScript{
Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell),
Location: to.Ptr("westus"),
Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{
CleanupPreference: to.Ptr(armdeploymentscripts.CleanupOptionsAlways),
Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""),
RetentionInterval: to.Ptr("PT7D"),
ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"),
SupportingScriptUris: []*string{
to.Ptr("https://uri1.to.supporting.script"),
to.Ptr("https://uri2.to.supporting.script")},
Timeout: to.Ptr("PT1H"),
AzPowerShellVersion: to.Ptr("1.7.0"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %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 = armdeploymentscripts.ClientCreateResponse{
// DeploymentScriptClassification: &armdeploymentscripts.AzurePowerShellScript{
// Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell),
// Location: to.Ptr("westus"),
// Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{
// CleanupPreference: to.Ptr(armdeploymentscripts.CleanupOptionsAlways),
// Outputs: map[string]any{
// "output1": "value1",
// },
// ProvisioningState: to.Ptr(armdeploymentscripts.ScriptProvisioningStateSucceeded),
// Status: &armdeploymentscripts.ScriptStatus{
// ContainerInstanceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer"),
// EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()),
// ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()),
// StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()),
// StorageAccountID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage"),
// },
// Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""),
// RetentionInterval: to.Ptr("P7D"),
// ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"),
// SupportingScriptUris: []*string{
// to.Ptr("https://uri1.to.supporting.script"),
// to.Ptr("https://uri2.to.supporting.script")},
// Timeout: to.Ptr("PT1H"),
// AzPowerShellVersion: to.Ptr("1.7.0"),
// },
// },
// }
}
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 System.Xml;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Create_No_UserManagedIdentity.json
// this example is just showing the usage of "DeploymentScripts_Create" 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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "00000000-0000-0000-0000-000000000000";
string resourceGroupName = "script-rg";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ArmDeploymentScriptResource
ArmDeploymentScriptCollection collection = resourceGroupResource.GetArmDeploymentScripts();
// invoke the operation
string scriptName = "MyDeploymentScript";
ArmDeploymentScriptData data = new AzurePowerShellScript(new AzureLocation("westus"), XmlConvert.ToTimeSpan("PT7D"), "1.7.0")
{
CleanupPreference = ScriptCleanupOptions.Always,
SupportingScriptUris = { new Uri("https://uri1.to.supporting.script"), new Uri("https://uri2.to.supporting.script") },
ScriptContent = "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
Arguments = "-Location 'westus' -Name \"*rg2\"",
Timeout = XmlConvert.ToTimeSpan("PT1H"),
};
ArmOperation<ArmDeploymentScriptResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scriptName, data);
ArmDeploymentScriptResource result = lro.Value;
// 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
ArmDeploymentScriptData 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
Sample response
{
"kind": "AzurePowerShell",
"location": "westus",
"systemData": {
"createdBy": "string",
"createdByType": "Application",
"createdAt": "2020-02-01T01:01:01.1075056Z",
"lastModifiedBy": "string",
"lastModifiedByType": "Application",
"lastModifiedAt": "2020-02-01T01:01:01.1075056Z"
},
"properties": {
"provisioningState": "Creating",
"azPowerShellVersion": "1.7.0",
"scriptContent": "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
"arguments": "-Location 'westus' -Name \"*rg2\"",
"supportingScriptUris": [
"https://uri1.to.supporting.script",
"https://uri2.to.supporting.script"
],
"retentionInterval": "P7D",
"timeout": "PT1H",
"cleanupPreference": "Always",
"status": {
"containerInstanceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer",
"storageAccountId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage",
"startTime": "2018-11-13T15:19:45-08:00",
"endTime": "2018-11-13T15:19:45-08:00",
"expirationTime": "2018-11-13T15:19:45-08:00"
}
}
}
{
"kind": "AzurePowerShell",
"location": "westus",
"properties": {
"provisioningState": "Succeeded",
"azPowerShellVersion": "1.7.0",
"scriptContent": "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name",
"arguments": "-Location 'westus' -Name \"*rg2\"",
"supportingScriptUris": [
"https://uri1.to.supporting.script",
"https://uri2.to.supporting.script"
],
"retentionInterval": "P7D",
"timeout": "PT1H",
"cleanupPreference": "Always",
"status": {
"containerInstanceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer",
"storageAccountId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage",
"startTime": "2018-11-13T15:19:45-08:00",
"endTime": "2018-11-13T15:19:45-08:00",
"expirationTime": "2018-11-13T15:19:45-08:00"
},
"outputs": {
"output1": "value1"
}
}
}
Expand table
Object
Object model for the Azure CLI script.
Expand table
Name
Type
Default value
Description
id
string
String Id used to locate any resource on Azure.
identity
ManagedServiceIdentity
Optional property. Managed identity to be used for this deployment script. Currently, only user-assigned MSI is supported.
kind
string:
AzureCLI
Type of the script.
location
string
The location of the ACI and the storage account for the deployment script.
name
string
Name of this resource.
properties.arguments
string
Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'
properties.azCliVersion
string
Azure CLI module version to be used.
properties.cleanupPreference
cleanupOptions
Always
The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'.
properties.containerSettings
ContainerConfiguration
Container settings.
properties.environmentVariables
EnvironmentVariable []
The environment variables to pass over to the script.
properties.forceUpdateTag
string
Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID.
properties.outputs
object
List of script outputs.
properties.primaryScriptUri
string
Uri for the script. This is the entry point for the external script.
properties.provisioningState
ScriptProvisioningState
State of the script execution. This only appears in the response.
properties.retentionInterval
string
(duration)
Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day).
properties.scriptContent
string
Script body.
properties.status
ScriptStatus
Contains the results of script execution.
properties.storageAccountSettings
StorageAccountConfiguration
Storage Account settings.
properties.supportingScriptUris
string[]
Supporting files for the external script.
properties.timeout
string
(duration)
P1D
Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D
systemData
systemData
The system metadata related to this resource.
tags
object
Resource tags.
type
string
Type of this resource.
Object
Object model for the Azure PowerShell script.
Expand table
Name
Type
Default value
Description
id
string
String Id used to locate any resource on Azure.
identity
ManagedServiceIdentity
Optional property. Managed identity to be used for this deployment script. Currently, only user-assigned MSI is supported.
kind
string:
AzurePowerShell
Type of the script.
location
string
The location of the ACI and the storage account for the deployment script.
name
string
Name of this resource.
properties.arguments
string
Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2'
properties.azPowerShellVersion
string
Azure PowerShell module version to be used.
properties.cleanupPreference
cleanupOptions
Always
The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'.
properties.containerSettings
ContainerConfiguration
Container settings.
properties.environmentVariables
EnvironmentVariable []
The environment variables to pass over to the script.
properties.forceUpdateTag
string
Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID.
properties.outputs
object
List of script outputs.
properties.primaryScriptUri
string
Uri for the script. This is the entry point for the external script.
properties.provisioningState
ScriptProvisioningState
State of the script execution. This only appears in the response.
properties.retentionInterval
string
(duration)
Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day).
properties.scriptContent
string
Script body.
properties.status
ScriptStatus
Contains the results of script execution.
properties.storageAccountSettings
StorageAccountConfiguration
Storage Account settings.
properties.supportingScriptUris
string[]
Supporting files for the external script.
properties.timeout
string
(duration)
P1D
Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D
systemData
systemData
The system metadata related to this resource.
tags
object
Resource tags.
type
string
Type of this resource.
Enumeration
The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'.
Expand table
Value
Description
Always
OnExpiration
OnSuccess
Object
Settings to customize ACI container instance.
Expand table
Name
Type
Description
containerGroupName
string
minLength: 1 maxLength: 63
Container group name, if not specified then the name will get auto-generated. Not specifying a 'containerGroupName' indicates the system to generate a unique name which might end up flagging an Azure Policy as non-compliant. Use 'containerGroupName' when you have an Azure Policy that expects a specific naming convention or when you want to fully control the name. 'containerGroupName' property must be between 1 and 63 characters long, must contain only lowercase letters, numbers, and dashes and it cannot start or end with a dash and consecutive dashes are not allowed. To specify a 'containerGroupName', add the following object to properties: { "containerSettings": { "containerGroupName": "contoso-container" } }. If you do not want to specify a 'containerGroupName' then do not add 'containerSettings' property.
Enumeration
The type of identity that created the resource.
Expand table
Value
Description
Application
Key
ManagedIdentity
User
Object
Deployment scripts error response.
Expand table
Name
Type
Description
error
ErrorResponse
Error Response
Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.)
Object
The environment variable to pass to the script in the container instance.
Expand table
Name
Type
Description
name
string
The name of the environment variable.
secureValue
string
The value of the secure environment variable.
value
string
The value of the environment variable.
Object
The resource management error additional info.
Expand table
Name
Type
Description
info
object
The additional info.
type
string
The additional info type.
Object
Error Response
Expand table
Name
Type
Description
additionalInfo
ErrorAdditionalInfo []
The error additional info.
code
string
The error code.
details
ErrorResponse []
The error details.
message
string
The error message.
target
string
The error target.
Object
Managed identity generic object.
Expand table
Name
Type
Description
tenantId
string
ID of the Azure Active Directory.
type
ManagedServiceIdentityType
Type of the managed identity.
userAssignedIdentities
<string,
UserAssignedIdentity >
The list of user-assigned managed identities associated with the resource. Key is the Azure resource Id of the managed identity.
ManagedServiceIdentityType
Enumeration
Type of the managed identity.
Expand table
Value
Description
UserAssigned
Enumeration
State of the script execution. This only appears in the response.
Expand table
Value
Description
Canceled
Creating
Failed
ProvisioningResources
Running
Succeeded
Object
Generic object modeling results of script execution.
Expand table
Name
Type
Description
containerInstanceId
string
ACI resource Id.
endTime
string
(date-time)
End time of the script execution.
error
ErrorResponse
Error Response
Error that is relayed from the script execution.
expirationTime
string
(date-time)
Time the deployment script resource will expire.
startTime
string
(date-time)
Start time of the script execution.
storageAccountId
string
Storage account resource Id.
StorageAccountConfiguration
Object
Settings to use an existing storage account. Valid storage account kinds are: Storage, StorageV2 and FileStorage
Expand table
Name
Type
Description
storageAccountKey
string
The storage account access key.
storageAccountName
string
The storage account name.
Object
Metadata pertaining to creation and last modification of the resource.
Expand table
Name
Type
Description
createdAt
string
(date-time)
The timestamp of resource creation (UTC).
createdBy
string
The identity that created the resource.
createdByType
createdByType
The type of identity that created the resource.
lastModifiedAt
string
(date-time)
The timestamp of resource last modification (UTC)
lastModifiedBy
string
The identity that last modified the resource.
lastModifiedByType
createdByType
The type of identity that last modified the resource.
Object
User-assigned managed identity.
Expand table
Name
Type
Description
clientId
string
Client App Id associated with this identity.
principalId
string
Azure Active Directory principal ID associated with this identity.